Database Reference
In-Depth Information
In a class diagram, a visibility symbol precedes each attribute. The visibility symbol indicates whether
other classes can view or update the value in the attribute. The possible visibility symbols are public visibility
(
). With public visibility, any other class can view or
update the value. With protected visibility, only the class itself or public or protected subclasses of the class
can view or update the value. With private visibility, only the class itself can view or update the value. The
name of the attribute, a colon, and then the data type for the attribute follow the visibility symbol.
At each end of each association is an expression that represents the multiplicity, or cardinality, of the
relationship. Multiplicity indicates the number of objects that can be related to an individual object at the
other end of the relationship. UML provides various alternatives for representing multiplicity. In the alterna-
tive shown in Figure 9-24, two periods separate two symbols. The first symbol represents the minimum num-
ber of objects, and the second symbol represents the maximum number of objects. A second number of n
indicates that there is no maximum number of objects.
In the association between Customer and Orders, for example, the multiplicity for Customer is 1..1. This
multiplicity indicates that an order must correspond to at least one customer and can correspond to, at most,
one customer. In other words, an order must correspond to exactly one customer. The multiplicity for Orders
is 0..n, indicating that a customer can have as few as zero orders (that is, a customer does not have to have
any orders currently in the database) and that there is no limit on the number of orders a customer can have.
In the association between Orders and OrderLine, the multiplicity for OrderLine is 1..n rather than 0..n. This
multiplicity indicates that each order must have at least one order line but that the number of order lines is
unlimited. If, on the other hand, the multiplicity for OrderLine were 1..5, an order would be required to have
anywhere from one to five order lines.
You can also specify constraints, which are restrictions on the data that can be stored in the database.
You enter the constraint in the shape shown in Figure 9-25 and then connect the shape to the class to which
it applies.
รพ
), protected visibility (#), and private visibility (
306
Rep
#RepNum : char(2)
#LastName : char(15)
#FirstName : char(15)
#Street : char(15)
#City : char(15)
#State : char(2)
#Zip : char(5)
#Commission : decimal(7,2)
#Rate : decimal(3,2)
+AddRep( )
+DeleteRep( )
+ChangeAddress( )
+ChangeRate( )
+ChangeCommission( )
Part
#PartNum : char(4)
#Description : char(15)
#OnHand : decimal(4,0)
#Class : char(2)
#Warehouse : char(1)
#Price : decimal(6,2)
+AddPart( )
+DeletePart( )
+ChangePartData( )
+ChangeOnHand( )
+ChangePrice( )
Customer
#CustomerNum : char(3)
#CustomerName : char(35)
#Street : char(15)
#City : char(15)
#State : char(2)
#Zip : char(5)
#Balance : decimal(8,2)
#CreditLimit : decimal(8,2)
+AddCustomer( )
+DeleteCustomer( )
+ChangeAddress( )
+ChangeCreditLimit( )
+ChangeBalance( )
(CustomerName
is not null)
Constraints
(CreditLimit is $5,000, $7,500
$10,000, or $15,000)
1..1
1..1
0..n
1..1
Orders
#OrderNum : char(5)
#OrderDate : date
+AddOrder( )
+DeleteOrder( )
+ChangeOrderDate( )
0..n
OrderLine
#NumOrdered : decimal(3,0)
#QuotedPrice : decimal(6,2)
+AddOrderLine( )
+DeleteOrderLine( )
+ChangeOrderLine( )
0..n
1..1
1..n
FIGURE 9-25
Class diagram for the Premiere Products database with constraints
Search WWH ::




Custom Search