MySQL关系问题

发布于 2024-10-05 02:49:29 字数 134 浏览 0 评论 0原文

我有以下表格: - 消息 - 博客文章 - 图片 - 评论

新闻、博客条目和图片可以评论。我想保存评论表中的所有评论。

我的第一个想法是在评论表中创建一个referenceTo列,但是新闻、博客条目和图片可以有相同的id。

I have the following tables:
- news
- blogentries
- pictures
- comments

News, Blogentries and Pictures can be commented. I want to save all the comments in the comments-table.

My first idea was to make a referenceTo-column in the comments-table, but news, blogentries and picutres can have the same id.

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

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

发布评论

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

评论(1

痕至 2024-10-12 02:49:29

您可以有一列告诉您对象的类型 - 新闻、博客条目或图片。

您可能需要考虑使用 ENUM 列类型。

You can have a column which tells you the type of object - news, blog entry, or picture.

You might want to consider using the ENUM column type for this.

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