Sunday, March 5, 2017

Explain many-to-many relationship with example in DBMS

What is many-to-many relationship in DBMS, many-to-many relationship example, cardinality ratio many-to-many

Many-to-many relationship

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.

Example:
 
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

************








 








No comments:

Post a Comment

Featured Content

Multiple choice questions in Natural Language Processing Home

MCQ in Natural Language Processing, Quiz questions with answers in NLP, Top interview questions in NLP with answers Multiple Choice Que...

All time most popular contents

data recovery