Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
749 views
in Technique[技术] by (71.8m points)

entity relationship - When to use Associative entities?

Suppose there are two entities called Employee and Campaign. One employee can work on many campaigns. And one campaign can have many employees. I already know this is a many to many relationship.

And when drawing the ER diagram (in Chen notation), the relationship is symbolized by a diamond shape. But there is a separate symbol for associative entities, which symbolizes a many to many relationship between two entities.

1) So should I use the diamond shape or the associative entity shape (diamond inside a square) when drawing many to many relationships in er diagram in Chen's notation?
2) Do they both mean the same thing or different things?
3) If they are two separate things, how can I identify when to use which?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Associative entities are used when you need a relationship to be involved in a relationship.

For example:

Enrollment relationship ERD

For a normal many-to-many relationship between Student and Course, we would use just a diamond. However, if we want to associate Enrollment with Teacher, we can turn Enrollment into an associative entity.

Enrollment associative entity ERD

Phyiscally, our database looks like this:

Enrollment associative entity tables

Making Enrollment a ternary relationship in which the Teacher is an optional role would have much the same meaning (except it would be denormalized, having a nullable role).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...