Re: Nested Relations / RVAs / NFNF
Date: 4 Nov 2004 20:22:30 -0800
Message-ID: <4b45d3ad.0411042022.7bf60082_at_posting.google.com>
> Wow. Well, I'm sold. Anybody else ?
Below XDB2 script shows how to create two masses (2kg and 2.2kg) where their quantity is typed as integer or float. Then a ball's mass is set to 2kg. The ball's mass can be changed from the drop-down control which automatically lists both masses. It could also show 2.3 lb, 3/4 ton, 4.35e3 g, etc. And yes, the 2 in 2kg and the two 2's in 2.2kg are normalized to the one and only symbol 2 in the db. See www.xdb2.com/example/ex110.asp for details.
// Represent 2kg and 2.2kg where their qty is typed
// Create necessary classes
CREATE2 *mass.cls = thing; CREATE2 *qty.cls = thing; CREATE2 *unit.cls = thing; CREATE2 *type.cls = thing;
// Create qty 2 and type it as an integer
CREATE2 *;
CREATE2 it.name = +'2'; CREATE2 it.cls = qty; CREATE2 it.type = +integer;
// Create qty 2.2 and type it as a float
CREATE2 *;
CREATE2 it.name = +'2.2'; CREATE2 it.cls = qty; CREATE2 it.type = +float;
// Create mass 2kg
CREATE2 *;
CREATE2 it.cls = mass; CREATE2 it.qty = (%.cls=qty & %.name='2'); CREATE2 it.unit = +kg;
// Create mass 2.2kg
CREATE2 *;
CREATE2 it.cls = mass; CREATE2 it.qty = (%.cls=qty & %.name='2.2'); CREATE2 it.unit = +kg;
// Create a ball and set its mass to 2kg
CREATE2 *ball.cls = thing;
CREATE2 ball.mass = (%.cls=mass & %.qty=2 & %.unit=kg);
// Query to find mass(es) whose qty is typed as float
// Finds mass 2.2 kg
SELECT2 %.cls=mass & %.qty=(%.type=float);
Received on Fri Nov 05 2004 - 05:22:30 CET