You get a bonus - 1 coin for daily activity. Now you have 1 coin

See also - The entity-relationship modeling method

Lecture



Это окончание невероятной информации про метод моделирования сущность-связь.

...

font-size: 12px;">

In MS Office Visio, the relationship name, the relationship degree (cardinality), and the entity's membership class in the relationship are defined on the "Database Properties" tab, as shown in Fig. 6.7. The arrow on the relationship line points to the parent table.

The entity-relationship modeling method

enlarge image
Fig. 6.7. Defining the cardinality of the relationship between the "Employee" and "Education" entities

When identifying relationships, the focus is on discovering their characteristics. A relationship represents an interconnection between two or more entities. Each relationship is realized through the values of entity attributes; for example, an instance of the "Employee" entity (Fig. 6.6) is linked to an instance of the "Education" entity through matching values of the Employee ID attribute. In other words, when a relationship is created, one of the entities, called the child entity, gains a new attribute called a foreign key (FK) (in Fig. 6.6 this is the Employee ID attribute). Foreign key attributes are sometimes marked with the symbol (FK) after their name.

A relationship is a logical correlation between entities. Every relationship must be named with a verb or verb phrase: Relationship Name (Verb Phrase) – a phrase describing the relationship between the parent and child entities. The relationship name expresses some constraint or business rule and makes the diagram easier to read. Fig. 6.8 shows how a relationship is assigned a name.

The entity-relationship modeling method

enlarge image
Fig. 6.8. Naming the relationship between the "Employee" and "Education" entities

There are various types of relationships: an identifying relationship "one-to-many", a "many-to-many" relationship, and a non-identifying relationship "one-to-many". Different entity types are also associated with different relationship types.

There are two types of entities: dependent (Dependent entity) and independent (Independent entity). The type of an entity is determined by its relationship with other entities. An identifying relationship is established between an independent entity (the parent end of the relationship) and a dependent entity (the child end of the relationship).

An instance of a dependent entity is defined only through its relationship to the parent entity, i.e., in the structure in Fig. 6.8 information about a specialty cannot be entered and has no meaning without information about the employee who holds that specialty according to their education diploma. When an identifying relationship is established (shown as a solid line in the figure), the primary key attributes of the parent entity are automatically migrated into the primary key of the child entity (solid line). This operation of adding attributes to the child entity when creating a relationship is called attribute migration. In the child entity, such an attribute is considered a foreign key.

If the model is created using CASE tools, then when the database schema is generated, the primary key attributes will receive the NOT NULL property, which means it is impossible to insert a record into the "Employees" table without information about the employee's ID number.

When a non-identifying relationship is established (Fig. 6.9, dashed line), the child entity remains independent, and the primary key attributes of the parent entity migrate as non-key components of the child entity. A non-identifying relationship is used to link independent entities (Fig. 6.9).

The entity-relationship modeling method

enlarge image
Fig. 6.9. A non-identifying relationship

An instance of the "Employee" entity can exist regardless of any instance of the "Department" entity, i.e., an employee can work at the organization without being assigned to any department.

An identifying relationship is shown on the diagram as a solid line with a solid dot at the child end (see Fig. 6.8), while a non-identifying one is shown as a dashed line (see Fig. 6.9).

A "many-to-many" relationship (many-to-many relationship) can only be created at the logical model level. Fig. 6.10 shows an example of defining a many-to-many relationship. A doctor can see many patients, and a patient can be treated by several doctors. Such a relationship is denoted by a solid line with arrowheads at both ends.

A "many-to-many" relationship must be named with two phrases – one for each direction (in the example, "treats/is treated by"). This makes the diagram easier to read. The relationship in Fig. 6.10 should be read as: Doctor Patient, Patient Doctor.

The entity-relationship modeling method

enlarge image
Fig. 6.10. A "many-to-many" relationship

As noted above, relationships determine whether an entity is independent or dependent. There are several types of dependent entities.

Characteristic – a dependent child entity that is related to only one parent and, by its meaning, stores information about the characteristics of the parent entity.

Associative – an entity related to several parent entities. Such an entity contains information about the relationships between entities.

Naming – a special case of an associative entity that has no attributes of its own (only attributes of parent entities that migrated in as foreign keys).

Categorical – a child entity in an inheritance hierarchy.

An inheritance hierarchy (subtype relationship), or category hierarchy, is a special type of grouping of entities that share common characteristics. For example, an organization employs full-time staff (regular employees) and part-timers. From their common properties one can form a generalized entity (a generic ancestor) "Employee" (see Fig. 6.11) to represent information common to all types of staff. Information specific to each type can be placed in the categorical (descendant) entities "Regular Employee" and "Part-Timer".

An inheritance hierarchy is usually created when several entities have attributes that are conceptually shared, or when entities have conceptually shared relationships (for example, if "Regular Employee" and "Part-Timer" had a similarly meaningful "works at" relationship with the "Organization" entity), or when this is dictated by business rules.

For each category one can specify a discriminator – an attribute of the generic ancestor that shows how to distinguish one categorical entity from another (the Type attribute in Fig. 6.11).

The entity-relationship modeling method

Fig. 6.11. Inheritance hierarchy. Incomplete category

Category hierarchies are divided into 2 types – complete and incomplete. In a complete category hierarchy (Complete subtype relationship), every instance of the generic ancestor (the "Employee" entity, Fig. 6.12) must necessarily correspond to an instance in one of the descendants, i.e., in this example an employee must necessarily be either a part-timer, a consultant, or a permanent employee.

If a category has not yet been fully built out, and instances may exist in the generic ancestor that have no corresponding instances among the descendants, then such a category is incomplete (Incomplete subtype relationship). Fig. 6.11 shows an incomplete category – an employee can be not only permanent or a part-timer, but also a consultant, however the "Consultant" entity has not yet been added to the inheritance hierarchy.

Fig. 6.12 shows an example of a complete category.

The entity-relationship modeling method

enlarge image
Fig. 6.12. Inheritance hierarchy. Complete category

A complete category is marked with the symbolThe entity-relationship modeling method, an incomplete one with–The entity-relationship modeling method.

A combination of complete and incomplete categories is possible. Besides permanent employees and part-timers there may also be consultants, who may not be reflected in the hierarchy (incomplete category), but every permanent employee is either male or female (complete category).

Let us consider the possible stages of building an inheritance hierarchy.

  1. Identifying entities with attributes that are common (by definition).

    Suppose that during the design process the entities "Regular Employee" and "Part-Timer" were created (Fig. 6.13). One can notice that some of the attributes of these entities (Last Name, First Name, Middle Name, Date of Birth, Position) have the same meaning.

    The entity-relationship modeling method

    Fig. 6.13. Entities with conceptually shared attributes
  2. Moving the common attributes to a generic ancestor entity. When conceptually matching attributes are found, a new entity "Employee" – a generic ancestor – should be created, and the common attributes (Last Name, First Name, Middle Name, Date of Birth, Position) moved into it.
  3. Creating an incomplete category structure. A categorical relationship is created from the new generic-ancestor entity to the old descendant entities. The new entity is supplemented with a category discriminator attribute (Type) (see Fig. 6.11).
  4. Creating a complete category structure. An additional search is conducted for entities that have attributes conceptually shared with the generic ancestor. In the example, this is the "Consultant" entity (Fig. 6.14).
    The entity-relationship modeling method

    Fig. 6.14. An additional entity with conceptually shared attributes
    The common attributes are moved into the generic ancestor, and the category is converted into a complete one. The "Consultant" entity does not have a Position attribute, so in the generic ancestor the value of this attribute will be NULL for a consultant. Depending on the business rules, the Position attribute may be moved back from the generic ancestor into the descendant entities "Regular Employee" and "Part-Timer".
  5. Combinations of complete and incomplete category structures. If necessary, building out the category hierarchy can be continued. For each descendant an entity with common attributes may be found, in which case the descendant entity becomes a generic ancestor for new descendants, and so on.

Normalizing the entity-relationship model

There are 3 sublevels of the logical level of the data model, differing in the depth of representation of information about the data:

  • the Entity Relationship Diagram (ERD);
  • the Key Based model (KB);
  • the Fully Attributed model (FA).

The entity-relationship diagram (ER diagram) displays the entities and interrelationships that reflect the main business rules of the subject domain; it includes the principal entities and the relationships between them that satisfy the basic requirements imposed on the information system. An entity-relationship diagram can show many-to-many relationships and need not include a description of keys. As a rule, ER diagrams are used for presentations and for discussing the data structure with subject-matter experts.

The key-based data model is a more detailed representation of the data. It includes a description of all entities and primary keys, and is intended to represent the data structure and keys that correspond to the subject domain.

The fully attributed model is the most detailed representation of the data structure: it represents the data in third normal form and includes all entities, attributes, and relationships.

Let us now consider the process of data normalization, which accompanies the creation of the fully attributed model.

Normalization – the process of checking and reorganizing entities and attributes in order to satisfy the requirements of the relational data model. Normalization ensures that every attribute is defined for its own entity, significantly reduces the amount of storage needed to hold the information, and eliminates anomalies in the way data is organized for storage. As a result of normalization, a data structure should be created in which information about each fact is stored in only one place.

The normalization process consists of successively bringing the data structure into normal forms – formalized requirements for the organization of data. Six normal forms are known:

  • first normal form (1NF);
  • second normal form (2NF);
  • third normal form (3NF);
  • Boyce-Codd normal form (a stronger 3NF);
  • fourth normal form (4NF);
  • fifth normal form (5NF).

In practice, one is usually limited to bringing data to third normal form. In this section the first three normal forms will be covered fairly briefly, along with fourth normal form as an illustration. For an in-depth study of normalization, the book [Date] is recommended.

Normal forms are based on the concept of functional dependency (hereafter the term "dependency" will be used). Let us give a formal definition of functional dependency.

Functional dependency (FD). Attribute B of entity E is functionally dependent on attribute A of entity E if and only if each value of A in E is associated with exactly one value of B in E, i.e., A uniquely determines B.

Full functional dependency. Attribute B of entity E is fully functionally dependent on a set of attributes A of entity E if and only if B is functionally dependent on A and is not dependent on any proper subset of A.

The entity-relationship modeling method

Fig. 6.15. The unnormalized "Employee" entity

In Fig. 6.15, in the "Employee" entity, the values of the attributes Last Name, First Name, and Middle Name are uniquely determined by the value of the Employee ID attribute, i.e., the attributes Last Name, First Name, and Middle Name depend on the Employee ID attribute.

Functional dependencies are determined by the business rules of the subject domain. Thus, if an employee's salary is determined only by their position, then the attribute Salary depends on the attribute Position; if the salary also depends, for example, on length of service, then no such dependency exists. In the examples below, for the sake of concreteness, we will assume that such a dependency does exist.

Let us consider the normal forms.

First normal form (1NF). An entity is in first normal form if and only if all attributes contain atomic values.

Attributes must not contain repeating groups, i.e., several values for each instance. In Fig. 6.15 the attributes Phone and Hobby may represent repeating groups and thereby violate the requirements of first normal form. An employee may have several work phone numbers or have several hobbies (fishing, hunting, swimming). Adding several attributes to the entity to represent the values of the repeating group is not a solution to the problem, since in most cases one cannot know in advance exactly how many such values there may be.

Storing values with different meanings in a single attribute violates the normalization requirements. In Fig. 6.15 the attribute Date of Hire or Termination stores information about both hiring and termination of an employee. If only one value is stored, it is impossible to tell which date has been entered. If a type flag attribute for the date is added, the type can be determined, but it would still only be possible to store one date per employee.

To bring an entity to first normal form, one should:

  • split composite attributes into atomic ones;
  • create a new entity;
  • move all "repeating" attributes into it;
  • choose a candidate key for the new PK (or create a new PK);
  • establish an identifying relationship from the original entity to the new one; the PK of the original entity becomes a foreign key (FK) in the new entity.

Fig. 6.16 shows the "Employee" entity brought to first normal form.

The entity-relationship modeling method

Fig. 6.16. The "Employee" entity brought to first normal form

Second normal form (2NF). An entity is in second normal form if it is in first normal form and every non-key attribute is fully dependent on the primary key (there must be no dependency on part of the key). Second normal form is meaningful only for entities that have a composite primary key.

The entity-relationship modeling method

Fig. 6.17. The "Project" entity

Suppose the "Project" entity contains information about a project managed by an employee, with the information covering both the project itself and the project manager (Fig. 6.17). The attributes Last Name, First Name, Middle Name, and Position depend only on the attribute manager's employee ID, but not at all on the attribute Project Name. In other words, there is a dependency on only part of the key.

To bring an entity to second normal form, one should:

  • identify the attributes that depend only on part of the primary key, and create a new entity;
  • place the attributes that depend on part of the key into their own (new) entity;
  • establish an identifying relationship from the original entity to the new one (Fig. 6.18).
The entity-relationship modeling method

Fig. 6.18. The "Project" entity brought to second normal form

Second normal form helps avoid the following anomalies when performing operations:

  • Update (UPDATE). Employee data gets duplicated if they manage several projects. If the employee's data changes, several records must be updated (as many as the number of projects they manage);
  • Insert (INSERT). It is impossible to enter data about an employee if they are not currently managing any projects;
  • Delete (DELETE). If an employee temporarily stops managing projects, the data about them is lost.

Fig. 6.18 shows the "Project" entity brought to second normal form.

Third normal form (3NF). An entity is in third normal form if it is in second normal form and no non-key attribute depends on another non-key attribute (there must be no interdependency among non-key attributes).

In Fig. 6.16 the "Employee" entity is in second normal form (there is only one primary key attribute, so there can be no dependency of non-key attributes on part of the key), but the non-key attribute Salary depends on another non-key attribute – Position.

To bring an entity to third normal form, one should:

  • create a new entity and move into it the attributes with the same dependency on a non-key attribute;
  • use the attribute (or attributes) that determines this dependency as the primary key of the new entity;
  • establish a non-identifying relationship from the new entity to the old one (Fig. 6.19).
The entity-relationship modeling method

enlarge image
Fig. 6.19. The "Employee" entity brought to third normal form

In third normal form, every attribute of an entity depends on the key, on the whole key, and on nothing but the key.

Third normal form also helps avoid a number of anomalies.

  • Update (UPDATE). Salary data gets duplicated if several employees hold the same position. If the salary corresponding to a position changes, several records must be updated (as many as the number of employees in that position).
  • Insert (INSERT). It is impossible to enter salary data corresponding to a position if there is currently no employee holding that position.
  • Delete (DELETE). If the employee holding a unique position is deleted from the table, the salary data is lost.

Fourth normal form (4NF) requires the absence of multivalued dependencies between attributes.

In the example in Fig. 6.20 (left), an instructor teaches lectures on several subjects and supervises several student groups. One student group may study several subjects, and one subject may be taught to several student groups. There is a multivalued dependency between the attributes Subject and Group. This can produce an anomaly: if an instructor gets a new group, several records must be added, one for each subject they teach.

To bring an entity to fourth normal form, one should create a new entity and move the attributes with the multivalued dependency into separate entities (Fig. 6.20, right). A relationship between the new entities must not be established in this case, since as a result of foreign-key attribute migration, the attributes with the multivalued dependency would once again end up in a single entity. Referential integrity in this case should be maintained using triggers.

The entity-relationship modeling method

Fig. 6.20. Illustration of fourth normal form

Summary

The entity-relationship modeling method was proposed by P. Chen in 1976. A number of researchers have developed several graphical notations for representing the elements of the model. A data warehouse designer can choose whichever graphical notation they prefer.

Applying the entity-relationship modeling method helps designers create a logical model of the subject domain that is independent of the specific software and hardware implementation. This method is used both when modeling the subject domains of OLTP systems and when modeling the subject domains of BI systems. Knowledge of this method helps a data warehouse designer more quickly establish the logical connections between the enterprise-scale OLTP system database models and the BI system data warehouse models.

Regardless of the notation chosen, the actions of a data warehouse designer during ER modeling come down to the following algorithm.

For each entity in the database's subject domain, it is necessary to:

  • obtain the list of the entity's attributes;
  • determine the functional dependencies;
  • determine the candidate keys, in particular by considering the entity's unique identifier;
  • perform normalization of the entity;
  • assign primary keys to the new entities resulting from normalization;
  • formulate the business rules for maintaining the entity's integrity.

For each relationship between entities, it is necessary to:

  • determine the cardinality of the relationship;
  • determine whether the entity's participation in the relationship is mandatory;
  • resolve many-to-many relationships;
  • assign primary keys to associative entities, based on the unique identifier of the relationship and the key migration procedure during normalization;
  • determine the non-key attributes of associative entities, if needed;
  • formulate the business rules for maintaining referential integrity of relationships;
  • document the logical model of the relational database;
  • verify the logical model of the relational database;

See also

  • Relational data warehouses
  • [[b4470]]
  • [[b6923]]
  • [[b9333]]
  • Entity-relationship modeling method (ER modeling)
  • Dimensional modeling method (Dimensional modeling)
  • Temporal data modeling methods (Temporal data modeling)
  • Data Vault modeling method (Data Vault)

Продолжение:


Часть 1 The entity-relationship modeling method
Часть 2 See also - The entity-relationship modeling method

See also

created: 2021-03-13
updated: 2026-03-10
296



Was this answer useful?
Choose a quick rating so we can improve the next answer for you.
How satisfied are you?


Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Databases, knowledge and data warehousing. Big data, DBMS and SQL and noSQL"

Terms: Databases, knowledge and data warehousing. Big data, DBMS and SQL and noSQL