标记系统设计问题

发布于 2024-11-28 01:02:13 字数 364 浏览 5 评论 0原文

我正在一个新闻网站上工作,我正在考虑实现一个标记系统(类似于此网站),您可以根据不同的类别类型对新闻进行分类,例如:新闻类别(经济、政治等),但是还有诸如编写语言和新闻文章类型(社论、专题报道等)之类的信息。

我应该如何区分这些不同的类别类型?我应该为每种类别类型提供一张标签表,还是应该将所有内容保留在一张表中并具有标签前缀,例如“语言:en”、“类别:经济”?第二种解决方案似乎更灵活,因为我只需添加前缀即可添加更多护理类型。然而,第一个解决方案感觉更加结构化并且更易于使用。

另外,我想知道您如何确定何时应将某些内容表示为标签或何时应将其表示为数据库中的列值/记录(例如,该语言应该是标签还是我的“新闻”表中是否有语言列?) 。我不知道该在哪里划清界限。

谢谢

I'm working on a news site and I'm thinking of implementing a tagging system (similar to this site) where you'll be able to categorize news by different category types such as: newscategory (economy, politics, etc.) but also things such as language it was written in and type of news article (editorial, feature story, etc.).

How should I distinguish between these different category types? Should I have one table of tags for each category type, or should I keep everything in one table and have a tag-prefix such as "language:en", "category:economy"? The second solution seems more flexible because I can add more caregory types just by appending a prefix. However the first solution feels more structured and easier to work with.

Also, I wonder how you determine when something should be represented as a tag or when it should be a column value/record in the database (e.g. should the language be a tag or do I have language column in my "News" table?). I'm not sure where to draw the line.

Thanks

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

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

发布评论

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

评论(1

生寂 2024-12-05 01:02:13

说标签本身可以按层次结构排序就足够了吗?如果是这样,只需将 parent_tag_id 添加到您的 tags 表中即可。

id  name          parent_tag_id
-------------------------------
1   language      null
2   english       1
3   french        1
4   newscategory  null
5   economy       4
6   politics      4

您可能将列视为静态字段,将行视为动态字段。保持较低的列数。语言可能是表中所有字段都应与一种语言相关联的列。

Would it be sufficient to say that the tags themselves could be ordered in a hierarchy? If so, just add a parent_tag_id to your tags table.

id  name          parent_tag_id
-------------------------------
1   language      null
2   english       1
3   french        1
4   newscategory  null
5   economy       4
6   politics      4

You might think of columns as static fields and rows as dynamic. Keep the number of columns low. Language might be a column of all fields in the table should be associated with a language.

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