Database Reference
In-Depth Information
￿
Objects can contain other objects. For example, the Rep object contains the Customer object as
one of its attributes. In the Rep object, the letters MV following the Customer object indicate
that the Customer object is multivalued. In other words, a single occurrence of the Rep object
can contain multiple occurrences of the Customer object. Roughly speaking, this is analogous to
a relation containing a repeating group.
￿
An object can contain a portion of another object. The Customer object, for example, contains
the Rep object. The word SUBSET indicates, however, that the Customer object contains only a
subset of the Rep object. In this case, the Customer object contains three of the Rep object
attributes: RepNum, LastName, and FirstName.
Notice that each of two objects can appear to contain the other. The Rep object contains the Customer
object, and the Customer object contains the Rep object (or at least a subset of it). The important thing to
keep in mind is that users deal with objects. If the users of the Customer object require access to the rep
'
s
number and name, the rep
s number and name are part of the Customer object. If the users of the Rep object
require data about all the customers of a sales rep, the Customer object is part of the Rep object. This
arrangement is not to imply, of course, that the data is physically stored this way, but this is the way its users
perceive the data.
Objects can contain more than one other object. Notice that the Orders object contains the Customer
object and the OrderLine object, with the OrderLine object being multivalued. Nevertheless, users of the
Orders object perceive it as a single unit.
Technically, the objects in Figure 9-21 are classes. The term class refers to the general structure. The
term object refers to a specific occurrence of a class. Thus, Rep is a class, whereas the data for rep 20 is an
object.
'
303
Methods and Messages
Methods are the actions defined for a class. Figure 9-22 shows two methods associated with the Orders
object. The first method, Add Order, adds an order to the database. In this example, users enter data, then
the program places the data temporarily in computer memory in a work area named WOrders. (In this exam-
ple, the W prefix indicates a temporary work area record or field.) The WOrders record consists of a user-
entered value for the order number stored in WOrderNum, a user-entered value for the order date stored in
WOrderDate, and so on.
Add Order (WOrders)
Add row to Orders table
OrderNum = WOrderNum
OrderDate = WOrderDate
CustomerNum = WCustomerNum
For each order line record in WOrders DO
Add row to OrderLine table
OrderNum = WOrderNum
PartNum = WPartNum
NumOrdered = WNumOrdered
QuotedPrice = WQuotedPrice
Update Part table (WHERE PartNum = WPartNum)
Allocated
= Allocated + WNumOrdered
Delete Order (WOrderNum)
Delete row from Orders table (WHERE OrderNum = WOrderNum)
For each OrderLine record (WHERE OrderNum = WOrderNum) DO
Delete row from OrderLine table
Update Part table (WHERE Part.PartNum = OrderLine.PartNum)
Allocated
= Allocated - NumOrdered
FIGURE 9-22
Two methods for the Premiere Products object-oriented database
Search WWH ::




Custom Search