Seminar 5
Enhanced ER
EER is an ER model bu with hierarchal relationships.
Entities that are member of one entity type (the superclass) may be grouped into meaningful subsets (the subclasses).
- Often referred to as an “is-A” relationship.
- The two subclasses of TRAINEE is the training courses company: EMPLOYEE and PROFESSIONAL.
Inheritance permits economy of representation.
Inheritance
An entity that is a member of a subclass inherits all of the attributes of the entity as a member of the superclass.
- A PROFESSIONAL, as a TRAINEE, has a code, name…
Also inherits all relationship types the superclass participates in.
- A PROFESSIONAL, as a TRAINEE, attends editions of courses.
When to Classify
Specialisation
Defining a set of subclasses of an entity type on the basis of some distinguishing characteristic of the entities in the superclass.
- Certain attributes may apply to some by not all members of an entity type:
- We keep Title and Area for professional trainees only:
- A subclass is defined to group the entities to which these attributes apply.
- We keep Title and Area for professional trainees only:
- Some relationship types may be participating in only by some members of an entity type:
- Employee trainees are the only trainees who work for an employer:
- A subclass is defined to group the entities participating to this relationship.
- Employee trainees are the only trainees who work for an employer:
Generalisation
Defining a superclass from a given set of entity types.
Inverse of specialisation as it involves realising that some entity types have lots of common features.
- The main idea is to suppress difference between entity types.
- Identify the common features an generalise them into a superclass:
- Generalise CAR and TRUCK into a VEHICLE superclass if a common behaviour is identified.
EER Notation
The two processes of generalisation and specialisation may use different notation but we will use the same notation.
You can find a summary of the full ER notation in the textbook or in this PDF.the notation mentioned here is notation e)(i) in the book.
- Subclasses are attached to a circle which is connected with the superclass.
- The subset symbol $\subset$ indicates direction of a relationship.
- Generic attributes are attaches to the superclass.
- Specific attributes are attaches to the subclasses.
Attribute-defined Subclasses
You can sometimes determine exactly the entities that will become members of each subclass
- For TRAINEE we may specify the condition of membership to be on the basis of the content of an attribute JobType.
This attribute is the defining attribute of teh specialisation
All subclasses in an attribute-defined specialisation must have the membership condition on the same attribute.
Predicate-defined Subclasses
Sometimes the membership condition depends on more than one factor:
- For TRAINEE
- For EMPLOYEE subclass we may specify the condition of membership to be: JobType=”Employee”
- We might have a subclass YOUNG representing all trainees with Age less than 30 no matter the job: Age < 30
We are therefore establishing membership on the basis of the truth value of a defining predicate.
Levels of Specialisation
We can have further specialisation of the same entity type using different distinguishing characteristics.
SALARIES and HOURLY-PAID are both EMPLOYEE and TRAINEE.
Disjointness Constraint
Specifies that subclasses of a specialisation are disjoint.
- An entity can be a member of at most one of the subclasses of the specialisation.
- Attribute defined specialisation implies disjoint subclasses if the defining attribute is single-valued.
Subclasses that are not disjoint may overlap.
- Some entities may be member of more than one subclass of the specialisation.
Completeness Constraint
This is similar to total and practical participation in regular relationships.
- Total Specialisation
- Every entity in a superclass must be a member of some subclass in some specialisation
- Ever EMPLOYEE must be either HOURLY-PAID or SALARIED.
- Every entity in a superclass must be a member of some subclass in some specialisation
- Partial Specialisation
- Allows an entity not to belong to any of the subclasses
- TRAINEES who are neither EMPLOYEES nor PROFESSIONAL.
- Allows an entity not to belong to any of the subclasses
Disjointness and completeness are independent.
This image states that EMPLOYEES must be paid but students don’t have to be PROFESSIONALS or EMPLOYEES.
Insertion & Deletion Rules
When implementing a database coming from an EER conceptualisation, we need to make sure the classification is preserved.
This is especially relevant when the DBMS does not support classes.
- Deleting an entity instance from a super class implies that it is automatically deleted from all of the subclasses it belongs to.
- Inserting an entity instance in a superclass implies that the entity is inserted in all predicate-defined subclasses for which the entity satisfies the defining predicate.
- Inserting an entity instance in a superclass of total specialisation implies that the entity is inserted in at least one of the subclasses of the specialisation.
- Inserting an entity in a superclass of disjoint, total specialisation implies that the entity is inserted in one and only one of the subclasses of the specialisation.