网站等广告的 DBMS 设计

发布于 2024-10-02 08:11:14 字数 246 浏览 0 评论 0原文

我不知道如何设计数据库管理系统来满足以下要求:

对于类似广告的网站,有很多类别。

每个类别都有可选的子类别。每个子类别可能有可选的子类别......等等。 根据每个类别(用户选择搜索),将有仅适用于该类别的搜索条件,例如:

如果用户选择了“汽车”类别,则将有以下搜索条件:制造商、型号、第一注册、燃料类型,但如果她选择公寓类别,则会有以下搜索条件:2 间卧室、3 间卧室、私人、代理 。

我希望我解释得尽可能简单。

I don't know how to design the dbms for the following requirement:

for an advertisement-like website there are a bunch of categories.

Every category has optional subcategories. Each subcategory may have optional subcategories ... and so on.
Depending on each category (the user has selected to search for) there will be search criteria which are applicable only to this category, for example:

if the user has chosen the category Autos there will be the following search criteria: make, model,first registration, fuel type, but if she chooses the category Flats there will be the following search criteria: 2 bedrooms,3 bedrooms, private, agency
.

I hope i explained it as simple as possible.

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

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

发布评论

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

评论(2

小糖芽 2024-10-09 08:11:14

这意味着要处理分层数据,因此有多种模型可供选择,每种模型都有其局限性和优点。

我建议阅读 http://articles.sitepoint.com/article/hierarchical-data-database 在实际开始设计架构之前。对于我的项目,我使用了邻接列表方法,因为它更容易理解,但是当您需要查询它时,一切都会变得困难,所以也许嵌套集会更好。

MySql似乎推荐嵌套集 http://mikehillyer.com/articles/managing- mysql 中的分层数据/

This means handling hierarchical data so there are many models to choose from, each one with it's limitations and advantages.

I would recommend reading http://articles.sitepoint.com/article/hierarchical-data-database before actually starting to design your schema. For my projects i've used the adjacency list approach because it's simpler to understand, but when you need to query it everything becomes difficult so maybe a nested set would be better.

MySql seems to recommend nested set http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/

拥醉 2024-10-09 08:11:14
table ad  [ad_id, category_id, {other fields}]
table category [category_id, name, parent_category_id(default=0)]

任何类别都可以有一个父类别,这样您就可以永远将它们脱壳
每个广告都有一个起始类别,如果该类别有子类别,则获取这些类别,如果它们有子类别,则无限获取这些广告

table ad  [ad_id, category_id, {other fields}]
table category [category_id, name, parent_category_id(default=0)]

any category can have a parent category so you can shell them forever
every ad has a starting category, if that category has children, then get those, if they have children then get those ad infinitum

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