Kroenke Dbp12e Appendix D PDF
Kroenke Dbp12e Appendix D PDF
Online Appendix D
E-R Diagrams and the UML Standard
Database Processing Appendix D
Appendix D 10 9 8 7 6 5 4 3 2 1
D-2
Database Processing Appendix D
Chapter Objectives
The Unified Modeling Language (UML) is a set of structures and techniques for modeling and designing
object-oriented programs (OOP) and applications. UML has come to prominence due to the Object
Management Group, an organization that has been developing OOP models, technology, and standards
since the 1980s. It is also beginning to see widespread use among OOP practitioners. In this appendix,
we are primarily interested in understanding the UML notation, and how it relates to IE Crows Foot no-
tation.
Because it is an application development methodology, UML is a subject for a course on systems devel-
opment and is of limited concern to us. However, some UML diagrams are used to model database de-
signs, and you may encounter them during your career. Accordingly, you should be familiar with their
style.
D-3
Database Processing Appendix D
Figure D-1 shows the UML representation of a 1:1, a 1:N, and an N:M HAS-A relationship. Each entity is
represented by an entity class, which is shown as a rectangle with three segments. The top segment
shows the name of the entity and other data that we will discuss. The second segment lists the names of
the attributes in the entity, and the third documents constraints and lists methods (program proce-
dures) that belong to the entity.
Relationships are shown with a line between two entities. Cardinalities are represented in the x..y car-
dinality format, where x is the minimum required and y is the maximum allowed. Thus, 0..1 means that
no entity is required and that at most one is allowed. An asterisk represents an unlimited number. Thus,
1..* means that one is required and an unlimited number is allowed.
D-4
Database Processing Appendix D
Figure D-2 shows the UML representation of weak entities. A filled-in diamond is placed on the line to
the parent of the weak entity (the entity on which the weak entity depends). In Figure D-2(a), PRESCRIP-
TION is the weak entity and PATIENT is the parent entity. All weak entities have a parent, so the cardi-
nality on their side of the weak relationship is always 1..1. Because of this, the cardinality on the parent
entity is shown simply as 1.
Figure D-2(a) shows a weak entity that is not an ID-dependent entity. It is denoted by the expression
<nonidentifying> on the PATIENT-PRESCRIPTION relationship. Figure D-2(b) shows a weak entity that is
ID-dependent. It is denoted with the label <identifying>.
Representation of Subtypes
UML represents subtypes and IS-A relationships, as shown in Figure D-3. In this figure, INDIVIDUAL,
PARTNERSHIP, and CORPORATE subtypes of CLIENT are allowed. According to this figure, a given CLIENT
could be one, two, or three of these subtypes. This does not make sense for this particular situation; a
CLIENT should be one and only one of these types. The current version of UML does not provide a
means to document exclusivity. Such notation can be added to a UML diagram, however.
D-5
Database Processing Appendix D
D-6
Database Processing Appendix D
Next, UML entity classes allow for class attributes. Such attributes differ from entity attributes because
they pertain to the class of all entities of a given type. Thus, in Figure D-4 PatientCount of PATIENT is an
attribute of the collection of all PATIENTs in the database. PatientSource is an attribute that documents
the source of all of the PATIENTs in the database.
As you will learn, such class attributes have no place to reside when using the relational model. Instead,
in some cases, attributes such as PatientCount are not stored in the database but are computed at run
time. In other cases, a new entity is introduced to contain the class attributes. For the entity in Figure D-
4, a new entity called PATIENT-SOURCE could be defined to hold both PatientCount and PatientSource
attributes. In this case, all of the entities in PATIENT are connected to PATIENT-SOURCE.
A third new feature is that UML uses object-oriented notation for the visibility of attributes and meth-
ods. Attributes preceded by a + are public, those with a # are protected, and those with a are private.
Thus in Figure D-4, Name in PATIENT is a protected attribute. These terms arise from the discipline of
object-oriented programming. A public attribute can be accessed and changed by any method of any
object. A public method can be invoked by any method of any object. Protected means that the attrib-
ute or method is accessible only by methods of this class or of its subclasses, and private means that the
attribute or method is accessible only by methods of this class.
Finally, UML entities specify constraints and methods in the third segment of the entity classes. In Figure
D-4, a primary key constraint is placed on PatientID. This simply means that PatientID is a unique identi-
fier. Additionally, Figure D-4 documents that GetName() is to be created to provide public access (note
the + in front of GetName) to the Name attribute; SetName() is to be used to set its value; and the
method GetPrescription() can be used to iterate over the set of Prescription entities related to this PA-
TIENT entity.
The ideas illustrated in Figure D-4 lie in the murky water where database processing and object-oriented
thinking merge. Such object-oriented notation does not fit with the practices and procedures of com-
mercial database processing today. The notion that an entity attribute can be hidden in an object does
not make sense unless only object-oriented programs are processing the database; even then, those
programs must process the data in conformance with that policy. This is almost never done.
Instead, most commercial DBMS products have features that allow all types of programs to access the
database and process any data that they have permission to access. Moreover, with facilities such as
SQL, there is no way to limit access to attribute values to a single object.
So, the bottom line is that you should know how to interpret UML-style E-R diagrams. They can be used
for database design just as extended E-R diagrams can. At present, however, the object-oriented nota-
tion they introduce is of limited practical value to database practitioners. The extended E-R model using
the crows foot notation is far more common and useful for database (as opposed to OO) design.
D-7
Database Processing Appendix D
Key Terms
<<persistent>> <identifying>
protected public
Review Questions
D-8