这个设计符合5NF吗?
一名用户只能拥有一个博客(该用户拥有该博客)
博客可以有多个帖子。
群组只能有一个博客(但没有特定用户拥有该博客,假设群组所有者创建了该博客,因此 userid 只是用户博客的属性,而不是群组博客的属性,因此需要子类型)
当删除 group_blog_post 时,底层的 blog_posts 行也应该被删除,这是最好使用触发器来完成吗?
A user can have only one blog (the user owns the blog)
Blogs can have multiple posts.
Groups can have only one blog (but no particular user owns the blog, it is assumed the group owner created the blog thus userid is only an attribute of user blogs not group blogs so subtyping is needed)
When group_blog_post is deleted, the underlying blog_posts row should be deleted as well, is this best accomplished using a trigger?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要使表处于 5NF 状态,它必须首先处于 4NF 状态。要处于 4NF 状态,必须首先处于 3NF 状态。依此类推,直至 1NF。
宽松地说,较低的范式与候选键和非素数属性之间的依赖关系有关。但我们能看到的唯一非素数属性是“title”和“is_private”。所以实在没办法说清楚。
以一张表为例,如果“group_users”没有其他列,则属于 5NF。
稍后
如果您像这样扩展表 group_users
那么您仍然处于 5NF 状态。 “user_type_id”列不仅仅依赖于 user_id——如果是的话,你就不会处于 2NF 中。但 user_type_id 不仅仅是用户的属性;它是用户的属性。它是该特定组中用户的一个属性。没有部分关键依赖;没有传递依赖;没有独立的、多值的事实;没有连接依赖性;所以它是5NF。
该结构只允许每个组的每个用户有一个 user_type_id。如果您认为用户应该在每个组中拥有多种用户类型,那么这
也是 5NF 中的情况。没有部分关键依赖;没有传递依赖;没有独立的、多值的事实;没有连接依赖性;所以它是5NF。
For a table to be in 5NF, it must first be in 4NF. To be in 4NF, it must first be in 3NF. And so on, down to 1NF.
Loosely speaking, the lower normal forms have to do with dependencies between candidate keys and non-prime attributes. But the only non-prime attributes we can see are "title" and "is_private". So there's really no way to tell.
To take one table as an example, "group_users" is in 5NF if it has no other columns.
Later
If you extend the table group_users like this
then you're still in 5NF. The column "user_type_id" isn't dependent only on user_id--if it were, you wouldn't be in 2NF. But the user_type_id isn't an attribute of the user alone; it's an attribute of the user in this particular group. No partial key dependencies; no transitive dependencies; no independent, multi-valued facts; no join dependencies; so it's in 5NF.
That structure allows only one user_type_id per user per group. If you think users should have multiple user types in each group, then this
is also in 5NF. No partial key dependencies; no transitive dependencies; no independent, multi-valued facts; no join dependencies; so it's in 5NF.