Page 47 - DCAP308_OBJECT_ORIENTED_ANALYSIS_AND_DESIGN
P. 47
Unit 4: Advanced Class Modelling – I
Notes
Example: In Figure 4.4 airportCode and airportName are two candidate keys for Airport.
The model species that each airportCode (such as IAH, HOU, STL, ALB) uniquely identifies an
airport. Each airportName (such as Houston Intercontinental, Houston Hobby, Lambert St.
Louis airport, and Albany NY airport) also uniquely identifies an airport.
Figure 4.4: Candidate Keys for a Class
We indicate a candidate key for a class with the notation CKn in braces next to the appropriate
attributes. The n is a number that differentiates multiple candidate keys. For a multi-attribute
candidate key, multiple attributes have the CKn designation with the same value of n.
Some may recognize the term “candidate key” from the database literature, but the notion of a
candidate key is a logical construct, not an implementation construct. It is often helpful to be
able to specify the constraint that one or more attributes taken together are unique. Relational
database managers and most object-oriented database managers can readily enforce candidate
keys.
4.1.5 Domains
A domain is the named set of possible values for an attribute. The notion of a domain is a
fundamental concept in relational DBMS theory, but really has broader applicability as a modeling
concept. As Figure 4.5 shows, an attribute name may be followed by a domain and default value.
The domain is preceded by a colon; the default value is preceded by an equal sign. Some
domains are infinite, such as the set of integers; others are finite.
Figure 4.5: Assign a Domain to an Attribute rather than Directly Assign a Data Type
An enumeration domain is a domain that has a finite set of values. The values are often important
to users, and you should carefully document them for your object models.
Example: You would most likely implement priority type in Figure 4.5 as an
enumeration with values that could include normal, urgent, and informational.
A structured domain is a domain with important internal detail. You can use indentation to
show the structure of domains at an arbitrary number of levels.
Example: In Figure 4.6 shows two attributes that have a structured domain. An address
consists of a street, city, state, mail code, and country. A birth date has a year, month, and day.
LOVELY PROFESSIONAL UNIVERSITY 41