开发者

database structure for static pages

please help me on this one:)

Most of the time I a开发者_开发知识库m creating static pages like Contact Us, About Us, FAQs etc

If I want to store some dynamic items in the page, how will my table look like?

Let's say for the FAQ page, I am to store the question and the answer on the database. For the contact page, I will store emails and and some other contact information. Does that mean I have to create a separate table for each?


Often times I've seen people create a table for Meta information. It resembles a key => value relationship, where the first field of a row is the name and the second is the value. So if you were to manage your global contact information in the database, you may have the following rows:

Meta-Data Table

Meta ID | MetaTitle      | Meta Value
---------------------------------------------------------
     01 | email_address   | some.guy@somedomain.com
     02 | phone_number    | 1.234.567.8901
     03 | num_subscribers | 2312
     04 | page_styles     | background-color:#333333;color:#ffffff

As for your frequently asked questions, you could do that as a table, if you like:

Questions

Question ID | Question          | Answer
-------------------------------------------
         01 | How tall are you? | Not nearly tall enough.

Or you could simply create a generic 'pages' table:

Pages

Page ID | Page Title | Page Content
--------------------------------------------
     01 | FAQs       | How tall are you?
        |            | Not nearly tall enough.
--------------------------------------------
     02 | Contact Us | Phone: 1.234.567.8901
        |            | Email: some.guy@somedomain.com


Based on the information provided, yes - it's quite likely you'll need separate tables.
Tables are just groupings of similar information, and email doesn't relate to questions & answers. With more information about what you're looking to do, and any business rules around it, we can help you with structure if you'd like.


You could just have 1 table which has a page id column and a page content column. The page id being different for each page you want to store in the database. And the page content column can be a text field which contains the HTML you want to display on that page. Then on each page you would query the database passing the parameter for the page content you wanted to display.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜