What is many-to-many relationship in DBMS, many-to-many relationship example, cardinality ratio many-to-many
If an entity [a record] of one entity set is associated with zero or more entities of the other entity set and vice versa then the cardinality ratio is said to be many-to-many.
When we would say the relationship is one-to-many?
Assume two entity sets A and B. The relationship between A and B is many-to-many if and only if “an entity in A is associated with zero or more entities (records) in B and an entity in B is associated with zero or more entities (records) in A”.
If we put in simpler terms, entity set B is the many side for A and entity set A is the many side for B.
In a University database let us consider two entity sets Student and Course. Assume that a student can register many courses that are offered and a course may be registered by many students per semester. Then the relationship between Student and Course will be many-to-many.
|Sample many-to-many relationship between entity sets|
Observe carefully from the above figure the following;
- Each student registered for zero or more courses [for example, Ravi registered for DBMS and Operating System]
- Each course is registered by zero or more students [ for example, DBMS is registered by Ravi, Mark, and Mary]
The ER diagram for this case is shown below;
|Many-to-many relationship Register between entity sets Student and Course|
Go to Important Keywords/Terms in DBMS page
Go to Advanced DBMS concepts page
Go to Some facts about relational tables page