Databases Reference
In-Depth Information
a
Customer (CID, Name, Address)
Order (OID, Order Date)
Shipment (SID, Date, Shipping Address)
Order Line (Position., Quantity)
Order Line (Position, Quantity)
Shipping Line (Position, OID, Order Line Position, Quantity)
Product (PID, Name, Unit Price)
Product (PID, Name, Unit Price)
b
Customer (CID, Name, Address)
Order (OID, Order Date)
Order Line (Position, Quantity)
Product (PID, Name, Unit Price)
Shipment (SID, Date, Shipping Address)
Shipping Line (Position, Quantity)
Product (PID, Name, Unit Price)
Fig. 2.3 Logical structures of the hierarchical customer order hierarchy. ( a ) No order/shipment
mapping. ( b ) Direct mapping of shipments to order lines
The hierarchical model contains several levels starting from a root node, each
level with nodes that act as the parents of the nodes on the next lower level if there
is a relation between them. Consequently, the hierarchical model is a set of one-
to-many relationships between parent and child nodes. Each node is stored as a
record that maintains links to the node's parent and its children. Different types of
nodes can be modeled in order to map diverse types of data entities, for example,
a customer entity that contains the name of the customer and his contact data,
or a product entity containing a description and pricing information. Applications
retrieve data from hierarchical databases by finding the root node of a tree and then
following the pointers stored in the records.
Figure 2.3 shows two alternative logical structures to model the customer order
hierarchy. Depending on frequent access paths one or the other alternative is of
advantage. Considering applications that frequently access shipments with no regard
of the associated orders, the structure in Fig. 2.3 a is beneficial as the depth of the
tree that needs to be traversed is kept at a minimum and the number of branches
correlates with the number of shipments. In contrast, shipments are scattered
across orders in Fig. 2.3 b, which benefits applications that rely on the relation
between orders and shipments, such as, reporting orders that have not been shipped
(completely).
 
Search WWH ::




Custom Search