静态页面的数据库结构

发布于 2024-08-15 14:12:56 字数 191 浏览 6 评论 0原文

请帮助我解决这个问题:)

大多数时候我都会创建静态页面,例如“联系我们”、“关于我们”、“常见问题解答”等。

如果我想在页面中存储一些动态项目,我的表格会是什么样子?

假设对于常见问题解答页面,我要将问题和答案存储在数据库中。对于联系页面,我将存储电子邮件和其他一些联系信息。这是否意味着我必须为每个表创建一个单独的表?

please help me on this one:)

Most of the time I am 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

终陌 2024-08-22 14:12:56

我经常看到人们为元信息创建一个表。它类似于一把钥匙 =>值关系,其中行的第一个字段是名称,第二个字段是。因此,如果您要在数据库中管理您的全球联系信息,您可能会有以下行:

元数据表

Meta ID | MetaTitle      | Meta Value
---------------------------------------------------------
     01 | email_address   | [email protected]
     02 | phone_number    | 1.234.567.8901
     03 | num_subscribers | 2312
     04 | page_styles     | background-color:#333333;color:#ffffff

至于您的常见问题,如果您愿意,您可以将其作为表格:

问题

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

或者您可以简单地创建通用“页面”表:

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: [email protected]

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   | [email protected]
     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: [email protected]
ぽ尐不点ル 2024-08-22 14:12:56

根据提供的信息,是的 - 您很可能需要单独的表。
表格只是相似信息的分组,电子邮件与问题和信息无关。答案。有了有关您想要做什么以及与之相关的任何业务规则的更多信息,如果您愿意,我们可以帮助您构建结构。

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.

笑脸一如从前 2024-08-22 14:12:56

您可以只有 1 个表,其中包含页面 id 列和页面内容列。对于要存储在数据库中的每个页面,页面 ID 都不同。页面内容列可以是一个文本字段,其中包含要在该页面上显示的 HTML。然后在每个页面上,您将查询数据库,传递您想要显示的页面内容的参数。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文