A connects entity sets. In the university database:
A relationship can have its own attributes. takes connects a student and a course, and has a grade.
A relationship set can connect an entity set to itself. prereq connects a course to another course. Each side has a role: the course, and its prerequisite.
Cardinality
The mapping cardinality says how many entities on the other side one entity can connect to:
| Cardinality | Means | Example |
|---|---|---|
| 1 : 1 | each A with at most one B, each B with at most one A | a member and a library card |
| 1 : N | each A with many B, each B with at most one A | a department and its courses |
| N : 1 | the same, read from the other side | courses and their department |
| M : N | each A with many B, each B with many A | students and the courses they take |
In a textbook ER diagram, an arrow points to the "one" side. A line with no arrow is the "many" side. Some books write limits on the line instead: 0..1, 1..1, 0..*, 1..*.
Participation
- Total: every entity of the set takes part in at least one relationship. Every course belongs to a department. A double line in the diagram.
- Partial: some entities take part in none. Not every student has an advisor. A single line.
The data shows when a rule is broken. It cannot prove a rule: the rules come from the requirements.