Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Chapter-3 ER Model

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

CHAPTER-3 The Enhanced E-R Model

Database Development Process


Objectives
- Define terms
- Understand use of supertype/subtype relationships
- Use specialization and generalization techniques
- Specify completeness and disjointness constraints
- Develop supertype/subtype hierarchies for realistic business situations

Supertypes and Subtypes


 Enhanced ER model: extends original ER model with new modeling constructs
 Subtype: A subgrouping of the entities in an entity type that has attributes distinct from those in other
subgroupings
 Supertype: A generic entity type that has a relationship with one or more subtypes
 Attribute Inheritance:
✓ Subtype entities inherit values of all attributes of the supertype
✓ An instance of a subtype is also an instance of the supertype

- 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.

Figure 3-1 Basic notation for supertype/subtype notation


EER Notation

This is only one


possible notation for
EER. In other figures
we will see Microsoft
Visio notation, which is
similar but not
identical.

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

Figure 3-3 Supertype/subtype relationships in a hospital

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.

Generalization and Specialization


 Generalization: The process of defining a more general entity type from a set of more specialized entity
types. BOTTOM-UP
 Specialization: The process of defining one or more subtypes of the supertype and forming
supertype/subtype relationships. TOP-DOWN

Figure 3-4 Example of generalization


a) Three entity types: CAR, TRUCK, and MOTORCYCLE
Sometimes during the conceptual
modeling process, we begin to
recognize common themes among
several entity types. For example they
may all share many of the same
attributes, such as in this example.
Here, cars trucks and motorcycles all
have prices, engine displacements and
vehicle makes and models.
All these types of vehicles have common attributes
3
Figure 3-4 Example of generalization (cont.)
b) Generalization to VEHICLE supertype

So we put the shared


attributes in a supertype

Note: no subtype for motorcycle, since it has no unique attributes


So, when this happens we can create a supertype and place the shared attributes in the supertype entity. This
process is called “generalization”.
The specialized attributes go into subtype entities. In the case of the motorcycle, there is no unique attribute, so
there is no need for a specific “motorcycle” entity.
Actually, it may be useful to have an indication that a vehicle is in fact a motorcycle. Later we will discuss the
concept of a “subtype discriminator”, which is a special attribute at the supertype level that identifies the specific
subtype.

Figure 3-5 Example of specialization


a) Entity type PART

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.

Note the representation of supplier as a composite multivalued attribute in this diagram.

4
Figure 3-5 Example of specialization (cont.)

b) Specialization to MANUFACTURED PART and PURCHASED PART

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.

Constraints in Supertype/SUBTYPE RELATIONSHIPS

 Completeness Constraints: Whether an instance of a supertype must also be a member of at


least one subtype
✓ Total Specialization Rule: Yes (double line)
✓ Partial Specialization Rule: No (single line)
There are two types of constraints in supertype/subtype relationships. One is called a completeness constraint,
and indicates whether there must be an explicit subtype for each possible instance of the supertype. The other
is called a disjointness constraint, which indicates whether a particular instance of a supertype could also be
more than one of the subtypes.

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.

Figure 3-6 Examples of completeness constraints (cont.)


b) Partial specialization rule

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

Figure 3-7 Examples of disjointness constraints


a) Disjoint rule

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.

Figure 3-7 Examples of disjointness constraints (cont.)


b) Overlap Rule

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.

Figure 3-8 Introducing a subtype discriminator (disjoint rule)

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?

Figure 3-9 Subtype discriminators (overlap rule)

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”.

Figure 3-10 Example of supertype/subtype hierarchy

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

Here, we clustered these 22 entities into


eight clusters. The relationships between
clusters occur if there are relationships
between entities within the individual
clusters. For example, since there is a 1:N
relationship between the Customer entity
and the Order entity, this implies a 1:N
relationship between the Customer
cluster and the Item Sale cluster.

Note that the associative entities often


stand apart from the clusters and provide
linkages between them.

Figure 3-14 Manufacturing entity cluster

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.

Packaged Data Models


 Predefined data models
 Could be universal or industry-specific
 Universal data model = a generic or template data model that can be reused as a starting point for
a data modeling project (also called a “pattern”)

Advantages of Packaged Data Models


 Use proven model components
 Save time and cost
 Less likelihood of data model errors
11
 Easier to evolve and modify over time
 Aid in requirements determination
 Easier to read
 Supertype/subtype hierarchies promote reuse
 Many-to-many relationships enhance model flexibility
 Vendor-supplied data model fosters integration with vendor’s applications
 Universal models support inter-organizational systems

Figure 3-15 PARTY, PARTY ROLE, and ROLE TYPE in a universal data model

Packaged data models are


generic models that can
be customized for a
particular organization’s
business rules.

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

You might also like