[英]Which fields in my database diagram should I separate into relation tables?
I am struggling with the issue of trying to understand whether or not data should be separated into different tables or kept within the same, in a database logical diagram.我正在努力解决试图了解数据是否应该在数据库逻辑图中被分成不同的表或保存在同一个表中的问题。
My database is split into 3 parts: users (can be registered users who can post, view or like recipes; and admins who review published recipes and can accept or block users), recipes (which contains data like: dish name, category, dificulty, duration, servings, execution, view count and state) and ingredients.我的数据库分为 3 部分:用户(可以是可以发布、查看或点赞菜谱的注册用户;以及审查已发布菜谱并可以接受或阻止用户的管理员)、菜谱(其中包含以下数据:菜名、类别、难度、持续时间、份量、执行、查看次数和状态)和成分。
Recipes and ingredients have a many: many relationship so I have connected those two with a relation table called "Recipe_Ingredient".食谱和配料有很多:很多关系,所以我用一个名为“Recipe_Ingredient”的关系表将这两者联系起来。
Users to recipes has a 1: many relationship (one user can create many recipes, but each recipe can only be created by one user), but also a relation table connecting them because of the favorites section (ie one user can have many recipes as favorite, and each recipe can also be flagged as favorite by many users).用户与菜谱有 1: many 的关系(一个用户可以创建多个菜谱,但每个菜谱只能由一个用户创建),但由于收藏夹部分,还有一个连接它们的关系表(即一个用户可以拥有多个菜谱)最喜欢的,并且每个食谱也可以被许多用户标记为最喜欢的)。
But my actual problem is: I have separated from the table recipes a few fields (see image below for reference) such as Category, dificulty, and state.但我的实际问题是:我已经从表格配方中分离出几个字段(参见下图以供参考),例如类别、难度和 state。 Is this acceptable or are these fields better off kept within table recipes?
这是可以接受的还是这些字段最好保留在表格食谱中?
Photo of what I have so far, for reference我目前的照片,供参考
Sorry for the long message.对不起,很长的消息。 Thank you so much for your help!
非常感谢你的帮助!
I think the tables as you have them are mostly fine because as your data increases that's when you see the value of the design.我认为您拥有的表格大部分都很好,因为随着数据的增加,您就会看到设计的价值。 Here are a few ideas you can use for making these decisions if looking for optimizations:
在寻找优化时,您可以使用以下一些想法来做出这些决定:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.