数据库MN关系[英] Database MN relationship

本文是小编为大家收集整理的关于数据库MN关系的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我正在参加数据库管理系统(绝对初学者)上的课程,并且正在为一个非常简单的博客系统进行数据库.

我有一个关于博客文章和帖子所属类别之间的一个m:n关系的问题(一个博客文章可以分为几个类别.)

该方案的一部分看起来像这样: 方案

我知道该方案允许以某种方式添加不属于任何类别的博客文章.但是,我不知道为什么那是.有人可以向我解释一下吗?

谢谢.

推荐答案

这可能是两件事的组合.其中一个是您的数据库设计中缺乏参考完整性,即您需要外键.另一个是您的前端应用程序允许发布博客,而没有类别的发布.

其他推荐答案

因为您可以添加一个blog_posts记录,而无需添加关联的post_cat记录.

本文地址:https://www.itbaoku.cn/post/597357.html

问题描述

I'm taking a class on database management systems (absolute beginner) and I'm working on a database for a very simple blog system.

I have a question regarding one M:N relationship between blog posts and categories where the posts belong (one blog posts can be in several categories.)

The part of the scheme looks like this: Scheme

I know that somehow this scheme allows to add a blog post that doesn't belong to any category. However, I don't know why that is. Could someone please explain this to me?

Thanks.

推荐答案

It's probably a combination of two things. One would be a lack of referential integrity in your database design, ie you need foreign keys. The other would be that your front end application is allowing blogs without categories to be posted.

其他推荐答案

Because you can add a blog_posts record without having to add an associated post_cat record.