Chapter-3 ER Model
Chapter-3 ER Model
Chapter-3 ER Model
- The ideas of supertypes, subtypes and inheritance, which are central to the EER model, are also key
concepts in object-oriented software design and programming. If you ever use an object-oriented
programming language like Java or C++, you will encounter the concept of classes, which are similar to
“types”. These classes are arranged in hierarchies, which enable inheritance.
- The difference between object-oriented programming and EER supertypes/subtypes is that in object
oriented programming there is also the concept of behavior. Objects not only have attributes (which can be
inherited), but they also have “methods” which implement active behaviors.
1
Figure 3-1 Basic notation for supertype/subtype notation (cont.)
Different modeling tools may have different notation for the same modeling constructs.
Figure 3-2 Employee supertype with three subtypes
It makes sense to model supertypes and subtypes if certain attributes or relationships apply only to a subset of
the total entity type whereas others are shared across the entire entity type. In this case, all employees have
names, addresses, and hire dates. But only hourly employees have hourly rates, only salaried employees have
salaries and stock options, and only consultants have contract numbers and billing rates. If we simply had an
employee entity, then these special-purpose attributes would be irrelevant for many of the employees.
2
Relationships and Subtypes
Relationships at the supertype level indicate that all subtypes will participate in the relationship
The instances of a subtype may participate in a relationship unique to that subtype. In this situation, the
relationship is shown at the subtype level
This is a good example of the distinction between shared attributes/relationships and specialized
attributes/relationships. So, it makes sense to break patients into two subtypes.
Sometimes during conceptual modeling we discover that certain attributes (or relationships) apply only to a
subset of the entities in a given entity type. In this example, we have a manufacturing firm that may manufacture
some of its own parts and purchase others. If the part is manufactured by the firm itself, it has a routing number,
but if purchased it does not. If purchased, it comes from a supplier, but if manufactured it does not.
4
Figure 3-5 Example of specialization (cont.)
When we fine a situation like this, it makes sense to do “specialization”. In this case, we created two subtypes of
Part, one for manufactured parts and one for purchased part. All parts have part numbers, descriptions, locations,
and quantity. But only manufactured parts have routing numbers, and only purchased parts have suppliers.
Note that unlike the previous slide, the concept of supplier is now represented as a separate entity, and an
associative entity represents a M:N relationship between purchased part and supplier, with unit price being an
attribute of the associative entity.
This provides information that was not explicit in the previous figure. A multivalued attribute does not explicitly
describe a M:N relationship. It could also convey a 1:N relationship. But when you represent the supplier as a
separate entity, you can explicitly show the cardinality of relationship.
For an example of a multivalued attribute that implies a 1:N relationship, refer to figure 2.19 from chapter 2. Here
we have time stamps of price history changes. For a given product, there may be many price history items, but each
price history item belongs to only one product. That’s different from what we have here with parts and suppliers,
where a part can have many suppliers and a supplier could supply many parts.
5
Figure 3-6 Examples of completeness constraints
a) Total specialization rule
In this case, a patient MUST either be an outpatient or a resident patient. There is no other possibility. This
particular completeness constraint is called total specialization, and is represented by double lines coming down
from the supertype entity type.
We already saw this example from earlier. This is partial specialization, because some vehicles are motorcycles,
which is not explicitly represented as a subtype entity.
Question: going back to figure 2-5, do you think the division of PART into manufactured vs. purchased parts
implies total specialization or partial specialization?
Answer: probably total specialization. Either a part is manufactured in-house or purchased from an external
supplier. There is probably no other option.
6
Constraints in Supertype/SUBTYPE RELATIONSHIPS
Disjointness Constraints: Whether an instance of a supertype may simultaneously be a
member of two (or more) subtypes
Disjoint Rule: An instance of the supertype can be only ONE of the subtypes
Overlap Rule: An instance of the supertype could be more than one of the subtypes
Here we see a disjoint (not overlap) rule regarding patients. A patient can’t be both a resident and an outpatient, at
least not at the same time. Of course it’s possible for a patient to be a resident for a period of time and then change
to an outpatient (or vice versa), but the patient cannot be both simultaneously.
Here is an overlap rule. Some kinds of parts could be manufactured in-house and also purchased from external
suppliers. Note the total specialization rule, which we discussed earlier.
7
Constraints in Supertype/SUBTYPE RELATIONSHIPS
Subtype Discriminator: An attribute of the supertype whose values determine the target
subtype(s)
Disjoint – a simple attribute with alternative values to indicate the possible subtypes
Overlapping – a composite attribute whose subparts pertain to different subtypes. Each
subpart contains a Boolean value to indicate whether or not the instance belongs to the
associated subtype
It is often useful at the supertype level to have an attribute that indicates which subtype an instance is. This is
easier to do with the disjoint rule than the overlap rule. For disjoint, there is only one possible subtype, but with
overlap there are many. That’s why the overlap rule requires a composite attribute.
Here, for the disjoint rule we have Employee Type as the subtype discriminator, and it can have three possible
values, one for each subtype.
Going back to figure 3-7, what would be a possible subtype discriminator, and what would its values be?
8
Note the requirement for a composite subtype discriminator here. So, there are three possible scenarios:
a. Manufactured = “Y” and Purchased = “Y”
b. Manufactured = “Y” and Purchased = “N”
c. Manufactured = “N” and Purchased = “N”
Note that it is impossible for this scenario to occur: Manufactured = “N” and Purchased = “N”. Why is this not
possible?
Answer: because of the total specialization rule. At least one of these have to be “Y”.
Supertype/subtype hierarchies can be as deep as we want them to be. Here we see that faculty is a type of
employee which is a type of person.
Question: Note here that a person must be an employee, alumnus, or student. Is it possible for a person to be both
an employee and a student? Why or why not?
Answer: yes, because of the overlap rule.
Question: Can you envision what the Person’s subtype discriminator would be?
Answer: It has to be a composite attribute.
Question: is it possible for an employee to be something other than Faculty or Staff? Why or why not?
Answer: yes because of partial specialization.
Question: is it possible for an employee to be both faculty and staff?
Answer: No, because of disjoint (not overlap) under Employee.
Question: is it possible for a staff member to also be a graduate student?
Answer: yes, because of the overlap rule under Person.
Question: is it possible for someone to have more than one degree from this university?
Answer: yes because Degree is a multivalued attribute.
9
3.1 Entity Clusters and Universal Data Model
Database Development Process
Objectives
- Develop entity clusters
- Explain universal (packaged) data model
- Describe special features of data modeling project using packaged data model
Entity Clusters
EER diagrams are difficult to read when there are too many entities and relationships.
Solution: Group entities and relationships into entity clusters.
Entity cluster: Set of one or more entity types and associated relationships grouped into a single
abstract entity type
Figure 3-13a Possible entity clusters for Pine Valley Furniture in Microsoft Visio
Here we see 22 entities. That’s a lot, and can be difficult to read and make sense of at an aggregate, summary level.
10
Figure 3-13b EER diagram of PVF entity clusters
You can imagine the entity cluster diagram to be a “bird’s eye view” model. The modeler can the “drill down” to see
detailed views of individual clusters.
Figure 3-15 PARTY, PARTY ROLE, and ROLE TYPE in a universal data model
Universal and packaged data models are useful because they are reusable and customizable. This is a good
example. Most companies will have entities similar to people, employees, contacts, suppliers, departments, bills,
etc. If this is given to you from the beginning, you don’t have to “reinvent the wheel”, and can instead tweak it to
your specific needs.
Figure 3-15 PARTY, PARTY ROLE, and ROLE TYPE in a universal data model
(b) PARTY supertype/subtype hierarchy
Here we see an alternative notation for supertype/subtype representations. E-R and EER models have various
ways they can be represented in diagrams. But conceptually they are all pretty similar.
12