Strong and weak relations between entity types. Unary relations. Recursive relation
Contents
- 1. The concept of strong and weak relations. How are strong and weak relations determined?
- 2. An example of strong relation for relation type 1:M
- 3. Examples of weak relations for relation type 1:M
- 4. Unary relations. Recursive relations. Example
- Related topics
Search other websites:
1. The concept of strong and weak relations. How are strong and weak relations determined?
A strong relation arises between types of entities in cases where the existence of one type of entity is impossible without another type of entity.
A weak relation arises between two types of entities in the case when there is no direct relationship between them. In this case, the relation is optional, that is, there may be situations where the relation between entities is not needed. Entity types are able to exist autonomously without each other.
⇑
2. An example of strong relation for relation type 1:M
Let it be necessary to build a database of the educational process in which the entities Group and Student are distinguished. The Student entity is weak in relation to the Group entity. This is because the Student is subordinate to the Group in which he is studying. There is a strong relation between Group and Student entities. A Student cannot study at an educational institution without being included in a certain Group. That is, a relation will always exist. Figure 1 shows the relationship between the Student and Group entities.
Figure 1. Relationship between Student and Group entities
⇑
3. Examples of weak relations for relation type 1:M
Example 1. When designing a database of an educational institution, a relationship may exist between the types of entities Worker (Teacher) and Cabinet. In this case, the Worker is a weak type of entity, the Cabinet is a strong type of entity. According to the staffing list, the Employee (Teacher) can be assigned as the head of the Cabinet, for which he receives a salary supplement. But this is not a prerequisite. Entity type Employee can exist autonomously without a premium for the Cabinet, as it has other sources of payroll. Therefore, between the entity types Worker (Teacher) and the Cabinet there is a weak relation, which is shown in Figure 2.
The presence of a weak relation is indicated by a small circle on the side of an optional entity. The communication capacity M has been set for the Employee, since several employees may receive allowances per Office (theoretically).
Figure 2. Weak relation between entity types Worker and Cabinet
Example 2. For entity types Student and Subject there is a relation. Student studies disciplines. In accordance with the curriculum, the student must study a certain list of disciplines throughout the study. However, some disciplines can be considered optional – those that the Student chooses for additional study. Assuming that there is an entity type Subject_Optional, there is a weak connection between the entity types Student and Subject_Optional, which is shown in Figure 3. With this method of database design, the entity type Subject is divided into two entity types: Subject_Mandatory and Subject_Optional. When creating a Subject_Optional relational table, student information is optional and may contain a NULL value.
Figure 3. The weak relation between Student and Subject_Optional entity types
⇑
4. Unary relations. Recursive relations. Example
Unary relation is a relation within a table. Unary relations are associated with recursive relations that close within the same table. Using recursive relations, you can conveniently describe complex hierarchical structures. Examples of such structures can be the hierarchy of the staffing level in an educational institution, the organizational and staffing structure of an enterprise, etc.
Example. Let the staffing structure of the positions of the educational institution be given. In the example, using the unary recursive connection, a diagram of the ER-model of the staff structure of the educational institution was developed (Figure 4).
Figure 4. Simplified organizational and staff structure of the institution’s positions
Figure 5 shows a unary-recursive relationship in an ER model diagram.
Figure 5. Unary-recursive relationship in an ER model diagram
If, based on the unary-recursive connection, a table is constructed, then the primary key ID_Position and the foreign key ID_Parent will be closed in this table. Figure 6 displays a data table that corresponds to the ER model shown in Figure 5.
⇑
Related topics
- The concept of ER-model. The concept of entity. Attributes. Attribute type
- Entity subtypes. Supertype. Example. Advantages and disadvantages of using subtypes of entities
- ER-model. The concept of relationship. The relationship capacity. Types of relationships. Examples
⇑