Tuesday, 21 August 2012

Composite Entities

  • Think back to relationship connectivity for a moment, 
  • We had 3 different types of connectivity.
    • One to One
    • One to Many
    • Many to Many
  • When finalizing your ERD's you should not leave many to many relationships in the diagram 
    • Many to Many relationship will cause a problem when we convert our ERD into the relational model.
  • We can eliminate many to many relationships by including composite entities in our diagram.
  • They replace relationship symbols in the ERD while being an entity as well.

Converting to Composite Entities

  • The first thing we need to do is to identify where in our ERD we have many to many relationship. 
  • If we spot any, we turn the relationship symbol into the composite entity symbol.
    • The composite entity is represented by combining the relationship(diamond) symbol with the entity symbol(box)
  • Entity names are usually nouns(objects) and relationship are usually described with a verb(action) 
  • Since the composite entity is more of an entity than a relationship, we should change the name of the relationship.
  • We then need to re-do the relationship connectivity. The class and student entity are no longer directly related to each other. 
  • The new relationship is now between the class and enrollment, and the student and enrollment.
  • We need to reconsider the connectivity between the 3 new entities.
    • Each class will have many enrollments and each student will have many enrollments as well.
  • We now have a composite entity, The composite entity like any other entities needs to have a key. 
  • In the case of a composite entity, we never give it its own ID number
  • In the case of a composite entity will always have a composite key that is the combination of the other two table's key,
    • Example, if the Class entity has a classID, and the Stident entity has a stuID, the composite entity's key will be ClassID and StuID.
free to give extra attributes to the composite entity. in this case let's gibe it an enrollment date.

No comments:

Post a Comment