No not all the content is necessarally stored in the database. The layout of the site will not change often enough for it to need to be stored in the db. Basically any content that won't be changing does not need to be stord in the database. You could do this, but the only possible reason I could think of storing all your static HTML in the database would be if you were going to provide some sort of form for the adinistrative user to modify this behind the scenes. Even then I think that I would store it in text files and include or write them as neeeded.
When it comes to the database you should only be storing data, not content. This means things that users enter into forms or data that will be used to generate dropdown boxes but not the actual forms or the select tags. The reasoning here is if you store the content in the database than you have lost a lot of the power having a database gives you. For example, we have a dropdown with colors. Occasionally as we think of a new color we want to add it to the website but don't want to have to go in and change the HTML by hand each and every time. Here is the display for that dropdown:
Code:
<%
Dim conn, rs, sql
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "MyDSN"
sql = "SELECT color_id, color_name FROM Colors"
Set rs = conn.Execute(sql)
If rs.EOF Then
Response.Write "Error, no colors in the database"
Response.End
End If
rs.MoveFirst
Response.Write "<select name=""selColors"">"
Do Until rs.EOF
Response.Write "<option value=""" & rs("color_id") & """>" & rs("color_name") & "</option>"
rs.MoveNext
Loop
Response.Write "</select>"
conn.Close
Set rs = Nothing
Set conn = Nothing
Now thats what the code would look like if we stored only the data in the database (in this case the colors). If also wanted to make a page where you could add new colors it would be relatively simple, basically a text entry box in a form that was submitted to another page that inserted that new color to the colors table.
On the other hand if we stored the whole select statement in the database:
Code:
<%
Dim conn, rs, sql
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "MyDSN"
sql = "SELECT html FROM Content WHERE name='selColor'"
Set rs = conn.Execute(sql)
If rs.EOF Then
Response.Write "Error, no colors in the database"
Response.End
Else
Response.Write rs("html")
End If
conn.Close
Set rs = Nothing
Set conn = Nothing
Now we have shortened our code and moved the content to the data base, but how will we change that data? If suddenly decide we want to also output the colors as a simple list in the html page then we would have to create a new database entry by hand and hope we didn't forget any of them, then when a new color was added we would have to add it to botht the selColor entry and the list entry.
That is the problem with mixing content and data. Once you mix them you no longer have any data and lose the power of the database, which is to allow you to store the data in a searchable format for any use, rather than store the content for a single use. Beyond that we also would then have to select that content from the database for every little thing we wanted to display. This would be extremely slow as we are not only requesting more data, but probably making more requests as well.
hope this helped,
-Tarwn
01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website