MySQL关系问题
我有以下表格: - 消息 - 博客文章 - 图片 - 评论
新闻、博客条目和图片可以评论。我想保存评论表中的所有评论。
我的第一个想法是在评论表中创建一个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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以有一列告诉您对象的类型 - 新闻、博客条目或图片。
您可能需要考虑使用 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.