Database Reference
In-Depth Information
Q&A
Question: Describe the steps in the Add Order method.
Answer: The steps accomplish the following:
￿
Add a row to the Orders table for the new order.
￿
For each order line record associated with the order, add a row to the OrderLine table.
￿
For each matched order line record, update the Allocated value in the Part table for the
corresponding part.
In Figure 9-22, the second method, Delete Order, deletes an order. The only data a user inputs to this
method is the order number to be deleted, which is placed temporarily in WOrderNum.
304
Q&A
Question: Describe the steps in the Delete Order method.
Answer: The steps accomplish the following:
￿
Delete the order with the user-entered order number (WOrderNum) from the Orders table.
￿
For each order line record in which the order number matches the value of WOrderNum, delete
the record.
￿
For each matched order line record, subtract the NumOrdered value from the Allocated value for
the corresponding part in the Part table. (Because the method deletes the order line record, the
parts are no longer allocated.)
NOTE
The two methods in Figure 9-22 are fairly complicated, consisting of several steps with each step involving separate updates to
the database. Many methods are much simpler, although some methods are even more complicated.
You define methods during the data definition process. To execute the steps in a method, a user sends a
message to the object. A message is a request to execute a method. As part of sending the message to an
object, the user sends the required data (for example, full order data for the Add Order method, but only the
order number for the Delete Order method). The process is similar to the process of calling a subroutine or
invoking a procedure in a standard programming language.
Inheritance
A key feature of object-oriented systems is inheritance. For any class, you can define a subclass. Every occur-
rence of the subclass is also considered an occurrence of the class. The subclass inherits the structure of the
class as well as its methods. In addition, you can define additional attributes and methods for the subclass.
As an example, suppose Premiere Products has a special type of order that has all the characteristics of
other orders. In addition, it contains a freight amount and a discount that are calculated in a special way.
Rather than create a new class for this type of order, you can define it as a subclass of the Orders class. In
that way, the special order type automatically has all the attributes of the Orders class. The new subclass also
has all the same methods of the Orders class, including the update of the Allocated field in the Part table
whenever orders are added or deleted. The only thing you would have to add would be those attributes and
methods that are specific to this new type of order, thus greatly simplifying the entire process.
Unified Modeling Language (UML)
The Unified Modeling Language (UML) is an approach you can use to model all the various aspects of soft-
ware development for object-oriented systems. UML includes a way to represent database designs.
Search WWH ::




Custom Search