dbTalk Databases Forums  

Demo: Relational Expressions

comp.databases.object comp.databases.object


Discuss Demo: Relational Expressions in the comp.databases.object forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Neo
 
Posts: n/a

Default Demo: Relational Expressions - 11-09-2004 , 03:16 PM






www.xdb2.com/example/ex005.asp demonstrates how to create and find
things using relational expressions. The example creates john with
black skin and red-blue hair; and mary with smooth-white skin and red,
silky-smooth hair using the script shown below. When executing a
query, the appropriate nodes are highlighted successively.

// Create person, skin, hair, color and texture classes
CREATE2 *person.cls = thing;
CREATE2 *skin.cls = thing;
CREATE2 *hair.cls = thing;
CREATE2 *color.cls = thing;
CREATE2 *texture.cls = thing;

// Create black skin
CREATE2 *;
CREATE2 it.cls = skin;
CREATE2 it.color = +black;

// Create smooth-white skin
CREATE2 *;
CREATE2 it.cls = skin;
CREATE2 it.color = +white;
CREATE2 it.texture = +smooth;

// Create red-blue hair
CREATE2 *;
CREATE2 it.cls = hair;
CREATE2 it.color = +red;
CREATE2 it.color = +blue;

// Create red, silky-smooth hair
CREATE2 *;
CREATE2 it.cls = hair;
CREATE2 it.color = +red;
CREATE2 it.texture = +silky;
CREATE2 it.texture = +smooth;

// Create a person named john
// with black skin and red-blue hair
CREATE2 *john.cls = person;
CREATE2 john.skin = (%.cls=skin & %.color=black);
CREATE2 john.hair = (%.cls=hair & %.color=red & %.color=blue);

// Create a person named mary
// with smooth-white skin and red, silky-smooth hair
CREATE2 *mary.cls = person;
CREATE2 mary.skin = (%.cls=skin & %.color=white & %.texture=smooth);
CREATE2 mary.hair = (%.cls=hair & %.color=red & %.texture=silky &
%.texture=smooth);

// Queries that find john
SELECT2 %.cls=person & %.hair=(%.color=blue);
SELECT2 %.cls=person & %.hair=(%.color=red & %.color=blue);
SELECT2 %.cls=person & %.skin=(%.color=black);
SELECT2 %.cls=person & %.skin=(%.color=black) & %.hair=(%.color=red &
%.color=blue);

// Queries that that find mary:
SELECT2 %.cls=person & %.hair=(%.texture=silky);
SELECT2 %.cls=person & %.hair=(%.color=red & %.texture=silky);
SELECT2 %.cls=person & %.skin=(%.color=white & %.texture=smooth);
SELECT2 %.cls=person & %.hair=(%.color=red & %.texture=silky &
%.texture=smooth);

// Queries that that find john and mary:
SELECT2 %.cls=person; // Any person
SELECT2 %.skin; // Any thing with skin
SELECT2 %.hair; // Any thing with hair
SELECT2 %.hair=(%.color=red); // Any thing with red hair

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.