Re: Nested Relations / RVAs / NFNF
Date: 27 Oct 2004 13:15:33 -0700
Message-ID: <4b45d3ad.0410271215.304b076d_at_posting.google.com>
Example of RVAs with XDB2:
// Create classes (order, orderItem, item, qty)
CREATE2 *order.cls = thing; CREATE2 *lineItem.cls = thing; CREATE2 *item.cls = thing; CREATE2 *qty.cls = thing; CREATE2 *size.cls = thing; CREATE2 *material.cls = thing;
// Create order1
CREATE2 *order1.cls = order;
// Create a lineItem with 5 bolts and make it part of order1
CREATE2 *; // Create a new thing, which can be referred to by "it"
CREATE2 it.cls = lineItem;
CREATE2 it.item = +bolt;
CREATE2 bolt.size = +"1/4 in";
CREATE2 it.qty = +5;
CREATE2 order1.part = it;
// Create a lineItem with 3 washers and make it part of order1
CREATE2 *;
CREATE2 it.cls = lineItem;
CREATE2 it.item = +washer;
CREATE2 washer.material = +teflon;
CREATE2 it.qty = +3;
CREATE2 order1.part = it;
On view of the above things in a tree format follows:
thing
inst: order
part: bolt 5 // auto generated label for line item item: bolt size = 1/4 in qty: 5 part: washer 3 // auto generated label for line item item: washer material: teflon qty: 3
Above is approximately equivalent to below (but without tables or NULLs):
Tbl_Order
OrderID Name
------ ------
1 order1
Tbl_LineItem
OrderID LineItemID ItemID Qty
------- ---------- ------ ---
1 1 1 5 1 2 2 3
Tbl_Item
ID Name Size Material
-- ----- ------ --------
1 bolt 1/4 in
2 washer teflon
// Query to find an order with a part (lineItem)
// where the lineItem quantity is 3
// and the item is made of teflon.
SELECT2 %.cls=order & %.part=(%.qty=3 & %.item=(%.material=teflon));
Note: cls/inst are abbreviations for class/instance. part/asm are abbreviations for part/assembly. These are predefined reciprocal relationships. Received on Wed Oct 27 2004 - 22:15:33 CEST