8/13/2019 080902_lecture3
1/35
Database Management SystemsSeptember 2, 2008
Lecture 3
Sections 4.1-4.5Enhanced Entity-Relationship Diagrams
8/13/2019 080902_lecture3
2/35
8/13/2019 080902_lecture3
3/35
REVIEW
8/13/2019 080902_lecture3
4/35
aka Extended Entity-Relationship Model adds Inheritance
indicates that one entity type isan extension of another entity type
often referred to as an IS-A relationship
8/13/2019 080902_lecture3
5/35
http://www.agilemodeling.com/artifacts/classDiagram.htm
8/13/2019 080902_lecture3
6/35
Inheritancedefines a subclass relationship A subclass inherits all properties (members) of the superclass
This is the perspectiveof most modern programming languages
8/13/2019 080902_lecture3
7/35
BA, C A Every B is also an A Every C is also an A
all entities
A
B C
everything true about a memberof a set is also true about anymember of its subsets.
8/13/2019 080902_lecture3
8/35
PhoneID
Name
Major Class Dept Office
PERSON
IsASTUDENT PROFESSOR
(not used in our textbook)
8/13/2019 080902_lecture3
9/35
PhoneID
Name
Major Class Dept Office
PERSON
STUDENT PROFESSOR
preferred notation: shows directionality of inheritance
8/13/2019 080902_lecture3
10/35
PhoneID
Name
Major Class Dept Office
PERSON
STUDENT PROFESSOR
The circle may be omitted when not needed.
8/13/2019 080902_lecture3
11/35
Student and professor entities have allattributes defined for a person,plus additional attributes
Keys are also inherited.
Subtypes should not define new keys.Phone
IDName
Major Class Dept Office
PERSON
STUDENT PROFESSOR
8/13/2019 080902_lecture3
12/35
8/13/2019 080902_lecture3
13/35
Disjointness: an entity can bea member of at most one subtype
a person may bea student or maybe a professor, butnot both
Covering: every entity of the supertypemust also be a member of at least one subtype
every person must be a professor ora student
8/13/2019 080902_lecture3
14/35
BA, C A B C =
all entities
A
B C
no entity is in both B and C
8/13/2019 080902_lecture3
15/35
BA, CA B C =
all entities
A
B C
an entity may be in both B and C
overlapping = non-disjoint
8/13/2019 080902_lecture3
16/35
BA, C A B C = A
all entities
B C
every entity in A is also in B or C
A
8/13/2019 080902_lecture3
17/35
BA, CA B C = A
all entities
A
B C
some entities in A are not in B or C
8/13/2019 080902_lecture3
18/35
IsA (triangle) notation:
write disjoint and/or coveringnext to the triangle
Subset notation,
d in the circledisjointness
o in the circle
no disjointness (overlap)required participation from supertypeindicates a covering constraint
8/13/2019 080902_lecture3
19/35
Every A can also be a B or a C, or both, or neither
A
IsA
B C
o
A
B C
8/13/2019 080902_lecture3
20/35
Every A can also be a B or a C or but not both
A
IsA
B C
d
A
B C
disjoint
8/13/2019 080902_lecture3
21/35
Every A must be a B or a C or both
A
IsA
B C
o
A
B C
covering
8/13/2019 080902_lecture3
22/35
Every A must be a B or a C, but not both
A
IsA
B C
d
A
B C
disjoint,
covering
8/13/2019 080902_lecture3
23/35
disjoint, covering inheritance:
every car is a vehicleevery truck is a vehicleevery vehicle is either a car or a truckno vehicle is both a car and a truck
8/13/2019 080902_lecture3
24/35
disjoint, non-covering inheritance:
employees may be secretaries, technicians or
engineers, but not more than one of these
8/13/2019 080902_lecture3
25/35
non-disjoint, covering inheritance:
every part is a manufactured part,or a purchased part,
or both (a purchased, manufactured part)
**How many attributes does a purchased, manufactured part have?** How would we model this in UML (C++ or Java)?
8/13/2019 080902_lecture3
26/35
**Interpret this schema.
** Can you find a real-world example?
8/13/2019 080902_lecture3
27/35
Multiple inheritance gives us a lattice,rather than a hierarchy
Inheritance Lattice
**Could we have engineering managers without defining the E_M class?
(compare to previous example)
8/13/2019 080902_lecture3
28/35
8/13/2019 080902_lecture3
29/35
8/13/2019 080902_lecture3
30/35
8/13/2019 080902_lecture3
31/35
Union defines a type as the union of other types OWNER = PERSON COMPANY OWNER is called a union type or category
OWNER is the subtype of the union of PERSON and COMPANY
Not multiple inheritance an OWNER does not need all the
attributes fromboth PERSON and COMPANY
OWNER
PERSON COMPANY
8/13/2019 080902_lecture3
32/35
A
B C
d
A
B C
B and C are subtypes of AB AB ABC A
A is a subtype of BC
ABC
8/13/2019 080902_lecture3
33/35
8/13/2019 080902_lecture3
34/35
8/13/2019 080902_lecture3
35/35