实体关系图
我想加深对 ER 图中基数约束的理解。
我有两个实体:
User
Location
但是,我希望这两个实体之间的关系是多对多(一个用户可以位于多个位置,一个位置可以位于多个位置)有很多用户)。
为此,我需要引入一个关联类UserLocation
。
我现在有 3 个实体,这样说是否正确?
如果我要绘制上面的 ER 图,我会绘制 UserLocation 实体吗?基数会像这样吗?
User 1 ------ * User Location * ------ 1 Location
I'd like to improve my understanding of cardinality constraints in ER diagrams.
I have two entities:
User
Location
But, I want the relationship between these two entities to be many-to-many (a user can be in many locations and a location can have many users).
To do this I need to introduce an association class UserLocation
.
Is it correct to say I now have 3 entities?
If I were to draw an ER diagam of the above, would I draw in the UserLocation
entity, and would the cardinality look like this?
User 1 ------ * User Location * ------ 1 Location
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不需要第三个实体。
在实体世界中,其建模如下:
在关系世界中,建模如下:
我相信在关系图中“中介”是不可见的。所以,我认为你需要这样的东西:
You do not need a third entity.
In the Entity world, this is modeled like this:
In the Relational world, this is modeled like this:
I believe that in the Relational diagram the "intermediary" is not visible. So, I think you would need something like this:
这完全取决于您正在执行的实体映射的类型和级别。
您可以将关系表示为
实体 1 <>实体2
例如用“乌鸦脚”来表示许多关系。
当规范化映射时,您将打破与中间表的多对多关系,这通常包含多个表的主键
Entity 1 > Entity 1实体3<实体 2
其中实体 3(您的中间表)将保存两个表的 PK,有时还保存任何其他数据,例如唯一 ID 等。
It all depends on the type and level of entitiy mapping you are doing.
You can express the relationship as it is
Entity 1 <> Entity 2
Such as using the 'Crows Feet' to represent the many relationship.
When normalising the map you would break up the many to many relationships with an intermediate table, this would normally contain the primary keys of both of the many tables
Entity 1 > Entity 3 < Entity 2
Where Entity 3 (your intermedite table) would hold PK's for both tables, and ocassionally any other data, such as a unique ID etc.