Re: Database planning - Hierarchical problem - Help needed
Date: 29 Nov 2004 11:02:20 -0800
Message-ID: <4b45d3ad.0411291102.19aaec09_at_posting.google.com>
> a problem i don't manage to resolve...
While it can be resolved using traditions dbs, the following script models the problem and runs some queries using an experimental db.
// Create various property classes
CREATE *age.cls = thing; CREATE *gender.cls = thing; CREATE *weight.cls = thing; CREATE *color.cls = thing; CREATE *profession.cls = thing; CREATE *race.cls = thing; CREATE *party.cls = thing; CREATE *SS#.cls = thing;
// Create persons each having a different property
CREATE *person.cls = thing;
CREATE *albert.cls = person;
CREATE albert.age = +30;
CREATE *john.cls = person;
CREATE john.gender = +male;
CREATE *bert.cls = person;
CREATE bert.weight = +180;
CREATE *chuck.cls = person;
CREATE chuck.color = +black;
CREATE *donna.cls = person;
CREATE donna.profession = +doctor;
CREATE donna.profession = +engineer;
CREATE *eddie.cls = person;
CREATE eddie.race = +asian;
CREATE *fred.cls = person;
CREATE fred.party = +republican;
CREATE *gilbert.cls = person;
CREATE gilbert.SS# = +333-22-4444;
// Create verbs for hierarchy
CREATE *boss.cls = verb;
CREATE boss.vbType = kr;
CREATE *employee.cls = verb;
CREATE employee.vbType = cr;
CREATE boss.opposite = employee;
// Create hierarchy
CREATE albert.employee = bert;
CREATE albert.employee = chuck;
CREATE john.employee = chuck;
CREATE chuck.employee = donna; CREATE chuck.employee = eddie; CREATE chuck.employee = fred;
CREATE eddie.employee = gilbert;
CREATE fred.employee = gilbert;
// Queries:
// Find person whose boss is eddie and fred.
// Finds gilbert.
SELECT %.cls=person & %.boss=eddie & %.boss=fred;
// Find person whose boss's boss is albert & john
// and has employee gilbert.
// Finds eddie and fred.
SELECT %.boss=(%.boss=albert) & %.boss=(%.boss=john) &
%.employee=gilbert;
// Find person whose is asian and has a boss whose boss is 30.
// Finds eddie.
SELECT %.cls=person & %.race=asian & %.boss=(%.boss=(%.age=30));
// Find person who is doc and eng,
// whose boss is someone whose employee is republican.
// Finds donna.
SELECT %.cls=person & %.profession=doctor & %.profession=engineer &
%.boss=(%.employee=(%.party=republican));
The reason the above works is because XDb2 is not based on theory. It uses random logic and an improbability drive interface directly to hardware bits within CPU's secondary cache. Received on Mon Nov 29 2004 - 20:02:20 CET
