Reputation: 55779
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
Upvotes: 0
Views: 965
Reputation: 356
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.
Upvotes: 1
Reputation: 7781
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:
User * ------- * Location
Upvotes: 1