The Entity Relationship Model

The Entity/Relationship (E/R) model is a high-level conceptual modeling approach used to represent the structure and semantics of a reference reality in a formal and abstract way. It serves as a foundational step in the design process of a database, typically carried out during the early stages of developing an information system for an organization or enterprise. The goal of the E/R model is to capture the key entities involved in the domain, their relevant attributes, and the relationships that exist among them, in order to create a clear and intuitive schema that reflects the logical structure of the data before it is implemented in a specific database management system (DBMS).

Entities

The basic elements are entities, characterized by attributes, or elements that characterize that entity. Entities These are classes of objects that have an autonomous existence in the reference scenario.

An entity is not an individual object, but a category of similar objects: for example, "Student," "Book," "Company" are all entities in different contexts. What makes an entity such is the fact that it can be identified and distinguished from others within the system, even if in an abstract way. Entities They can represent:

  • physical objects (e.g., a person, a car, a building),
  • abstract concepts (e.g., a university course, a project, an event).

Attributes

Each entity is characterized by attributes, which describe its relevant properties or characteristics. Attributes are therefore information elements associated with the entity: for example, the entity "Student" could have attributes such as name, student ID number, date of birth, and so on. street.

Attributes can be:

  • simple (e.g., a single value like "name");
  • compound (e.g., "address," which can include street, city, and ZIP code);
  • multivalued (if they can take on multiple values, e.g., telephone numbers);
  • derived (calculated from others, e.g., age from birth date).

Example

Imagine a university database. Some entities and their attributes could be:

  • Entity: Student
    Attributes: Student ID, First Name, Last Name, Date of Birth
  • Entity: Course
    Attributes: CourseCode, CourseName, CFU
  • Entity: Teacher
    Attributes: TeacherID, First Name, Last Name, Scientific Sector

Associations

Associations can be of different types:

  • one-to-one (1 to 1), each element of the first set (entity set) can be associated with only one element of the second set;
  • one-to-many (1 to N), each element of the first set can be associated with one or more elements of the second set, while each element of the second set is associated with one or more elements of the first set. associated with only one element of the first;
  • many-to-one (N to 1), corresponds to the association 1 to N, seen from the other side;
  • many-to-many (N to N), each element of the first set can be associated with one or more elements of the second set, while each element of the second set is associated with one or more elements of the first.

The associations 1 to N, N to 1, and N to N can be partial or total: they are total only if all the elements of the sets considered are involved, otherwise they are partial.