Mark As Completed Discussion

Entities and relations

The relational database model relies on entities and the relations between them.

Entities are specific objects or things in the real world that are being represented in the database.

Example: Employee John Smith, project ProductX, Development department, etc...

Attributes are some properties that are being used to describe the entity.

Example: The entity EMPLOYEE can have attributes: Name, SSN, Address, Sex, BirthDate

Every entity has values for every attribute defined.

Example: An Employee can be defined as: Name='John Smith', SSN='123456789', Address ='731, Fondren, Houston, TX', Sex='M', BirthDate='09- JAN-55‘

Every attribute has a value set or a data type that is associated with it. They can be simple, composite or multi-valued.

Example: Data type: Integer, string, subrange, enumerated type, etc... Multi-valued: An entity can have multiple values for a given attribute, like COLOR of a CAR.

Some attributes, that have a different value for each entity, can be defined as a key attribute of that entity. They can be simple or composite, and one entity can have multiple keys.

In the following diagram, we can see an example of a relational diagram for the entity CAR. The key attributes are underlined, and the multi-valued one is with double circles.

Entities and relations

The relations between certain entities can be of different types, and they can be:

  • 1:1 one to one
  • 1:N one to many
  • N:1 many to one
  • M:N many to many

Example: Employee - Department relationship has a N:1 relation. Meaning many employees can work for a single department.