In: Computer Science
I need an example of a composite entity replacing a m:n relationship in an Er diagram.
Need atleast three entities being used.
· Composite entity is an entity used to represent the relationship between any other 2 or more entities.
· That is a many-to-many relationship can be eliminated from the ER diagram using these composite entities.
· As many-to-many relationship can cause some problem while converting the ER diagram to relational model.
· Entities are usually some objects and the relationship connecting them are some actions performed among the entities.
Eg: consider the 3 entity relationship involving student, class, subject entity
Means: a student can be enrolled to many classes, a class can have many students
A student can study many subjects, a subject can be learnt by many students.
A class can have many subjects taught and a subject can be taught in many classes
This is how many-to-many relationship exhibited by the 3 given entities. (figure shown below)
Now these many-to-many relationship can be changed using composite entity.
Steps:
1. Identify the many-to-many relationship in the ER diagram (figure is shown below)
2. Then the relationship symbol(diamond) is changed to the composite entity symbol.(diamond symbol within the entity symbol, square)
3. Change the relationship name into an entity name
4. Now reconnect the relationship with the new arrived entity with the many-to-many relationship corrected to one-to-many.
5. Now each class will have many enrollments, each student will have many enrollments and each subject will have many enrollments (1:M relationship)
6. The composite entity will have a composite key, which is the combination of the primary keys of all the associated entities in 1:M relationship