需要两个同名的表 - 这个设计有什么问题?

发布于 2024-10-14 06:30:04 字数 351 浏览 1 评论 0原文

我同时从事两个网站项目。然而,这两个网站将如此互连,以至于它们共享同一个数据库。

对于第一个站点,我们将其称为汽车站点,我创建了一个名为“标签”的表,其中包含分配给条目的标签/标签/类别,非常类似于 SO 上的标签系统。现在我需要另一张桌子来保存与汽车无关的不同类型条目的标签。举例来说,假设我想标记衣服。

我已经有一个名为 car_tag 的表,它将汽车与标签连接起来。

我应该在同一个表中存储两种不同类型的“产品”的标签吗?我正在使用嵌套集模型,我认为这可能会变得非常混乱,有一天,条目上的某些内容会被损坏,网站用户会非常困惑。

有什么建议吗?标签1和标签2?我想稍后我可能需要更多标签来完成同一网站上不同但相关的项目。

I'm working on two website projects at once. However, the two websites will be so interconnected that they are sharing the same database.

For the first site, let's just call it a car site, I created a table called "tag" that holds tags/labels/categories that get assigned to entries, much like the tag system here on SO. Now I need another table to hold tags for a different type of entry, unrelated to the cars. For the sake of example, let's just say I want to tag clothing.

I already have a table called car_tag that joins cars with tags.

Should I be storing tags for the two different types of "products" in the same table? I'm using the nested set model and I think this could get quite confusing and the day something would get corrupted on the entries the website users would be extremely confused.

Any suggestions? Tag1 and Tag2? I think I might need even more tags later on for a different but related project on the same website.

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

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

发布评论

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

评论(2

寒江雪… 2024-10-21 06:30:04

只要标签服务于相同的语义目的,那么我不认为将它们组合到一个表中存在问题。您应该考虑添加 TagType/TagTypeId 字段来明确说明您要存储的标签类型(汽车、未命名实体)。

请记住,如果出于性能原因需要,您可以选择将它们拆分到不同的表中。

As long as the tags serve the same semantic purpose, then I don't see an issue with combining them into one table. You should consider adding a TagType/TagTypeId field to explicitly state which type of tag you're storing (cars, unnamed entity).

Just remember that you have the option of splitting them out to different tables if you need to for performance reasons.

无力看清 2024-10-21 06:30:04

同意——他们应该非常高兴坐在同一张桌子上。

事实上,如果它们代表相同的对象/概念,那么将它们放在单独的表中是不正确的。

我还认为您不需要以任何方式“拆分”标签。如果有red汽车和red衣服,那么如果它们都链接到同一个red标签会有什么危害?毕竟,有一天您可能需要找到带有 red 标签的所有内容。完全没有坏处。

Agree with - they should be perfectly happy to sit in the same table.

In fact, if they represent the same object / concept it would be incorrect to put them in separate tables.

I would also argue that you don't need to 'split' the tags in any way. If there are red cars and red clothes, then what would be the harm if they both link to the same red tag? You may someday need to find everything that has a red tag, after all. No harm at all.

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