gpt4 book ai didi

php - 网页附加内容的标准DB表结构?

转载 作者:行者123 更新时间:2023-11-29 08:58:19 25 4
gpt4 key购买 nike

我有这个页表结构来存储所有网站页面信息,

page_id
page_url
page_title
page_subtitle
page_description
page_introduction
page_content_1
page_content_2
page_content_3
page_content_4
...

您可以看到我有 page_content_1page_content_4,而不仅仅是 page_content。我这样做的原因是因为我可能想为每个页面存储不同类型的页面内容。

但我怀疑这是否是一个好的做法?如果其他开发者来对这个页表进行进一步开发,你会觉得这个结构多余吗?

我在想也许我应该创建另一个表来存储其他页面内容,如下所示?

page_additional_content

content_id
content_additional_1
content_additional_2
content_additional_3
content_additional_4
page_id

这样更好吗?

或者我应该研究更好的标准想法?

最佳答案

根据 Quentin 的答案,如果您希望能够跨页面重用内容(例如页眉或页脚),您可以创建一个表格结构,例如:

page_content: 
content_id (primary key)
actual_content (actual content of the page)
page_structure:
page_id (foreign key of the page)
content_id (foreign key of the content)
order_in_page (order of the content in the page)

您的内容可以增长到任意数量的部分,而无需添加额外的表格(只需在 page_struct 中添加新行并增加 order_in_page 计数器)。

关于php - 网页附加内容的标准DB表结构?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9330855/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com