Entity-Relationship Model 2/3

In the last article we have talked about attributes in the entity-relationship model.  We know that attributes describe entities, but another important thing for modeling a real-world system is describing the relationships between entities.  For example, if we have the Teacher and Class entities, we know that a teacher can teach multiple classes, and that one class can be taught by one or more teachers.  This association between a teacher and a class is called a relationship.

In the entity-relationship model, a relationship may also have some descriptive attributes.  However, each relationship must be uniquely identified by the participating entities.  This means that you can not have multiple relationships of the same type between two entities.  Relationships can be divided into groups by the number of entities which are participating in it.  The most common are binary relationships - which means that two entities are participating.  There are also some other kinds of restrictions when dealing with relationships, and the most significant are mapping cardinality and participation constraints.

The mapping cardinality constraint specifies, for a certain type of relationship, the maximum number of relationships in which a certain entity can participate.  For a binary relationship, the following options are possible:

  • one to one
  • one to many
  • many to one
  • many to many

For example, if we have a one-to-one relationship between Person and Passport, this means that a person can only have one passport, and a passport can only belong to one person.  Consequently, if we wished to store data about dual citizenships in our database, we would use a one-to-many relationship between Person and Passport, which would mean that a parson can have multiple passports, but still, a passport can only belong to one person.

Another type of relationship constraints we have mentioned is the participation constraint.  This constraint specifies the minimum number of relationships in which an entity needs to participate.  In the E-R model we can distinguish between two types of participation constraints: total and partial.  We say that the participation of an entity in a relationship is total if every instance of that entity has to participate in at least one relationship of that type.  This kind of constraint is also called "existence dependency", because an instance of that entity cannot exist without being in a relationship with another entity.

In the next article we will talk about one of the most important concepts in database modeling - keys (superkeys, primary and foreign keys).  Keys are closely related to the concept of uniqueness of entity instances, which we will discuss in more detail.  Once we understand this, we can continue with learning about the entity-relationship model, and make a simple model of a university.