Re: Relational vs network vs hierarchic databases

From: Neo <neo55592_at_hotmail.com>
Date: 11 Nov 2004 09:26:34 -0800
Message-ID: <4b45d3ad.0411110926.d3ee962_at_posting.google.com>


> With regards to what set of operations? Otherwise I'm going to stick > with my "string" answer, because it's easiest.

Use a RM db to model/represent the following things without NULLs or redundancy (I'll let redundant symbols slide). Then perform the queries listed at end:

john is a person whose profession is gardener. mary is a horse whose breed is mustang.
r2d2 is a robot whose cpu is 8051.
mary bite r2d2 before breakfast.
r2d2 hit mary during lunch.
(r2d2 hit mary during lunch) because (mary bite r2d2 before breakfast).
john reset r2d2 after dinner.
(john reset r2d2 after dinner) because (r2d2 hit mary during lunch).

Below script models the above in XDb2 (www.xdb2.com/example/ex113.asp) without NULLs or redundancy (including symbols):

// Create profession class

CREATE2 *profession.cls = thing;

// Create breed class

CREATE2 *breed.cls = thing;

// Create cpu class

CREATE2 *cpu.cls = thing;

// Create person named john who is a gardener
CREATE2 *person.cls = thing;
CREATE2 *john.cls = person;
CREATE2 john.profession = +gardener;

// Create horse named mary who is a mustang
CREATE2 *horse.cls = thing;
CREATE2 *mary.cls = horse;
CREATE2 mary.breed = +mustang;

// Create robot named r2d2 powered by a 8051 cpu
CREATE2 *robot.cls = thing;
CREATE2 *r2d2.cls = robot;
CREATE2 r2d2.cpu = +8051;

// Create verbs

CREATE2 *like.cls = verb;
CREATE2 *bite.cls = verb;
CREATE2 *hit.cls = verb;
CREATE2 *reboot.cls = verb;
CREATE2 *because.cls = verb;

// Create prepositions

CREATE2 *before.cls = preposition;
CREATE2 *during.cls = preposition;
CREATE2 *after.cls = preposition;

// Create meals

CREATE2 *meal.cls = thing;
CREATE2 *breakfast.cls = meal;
CREATE2 *lunch.cls = meal;
CREATE2 *dinner.cls = meal;

// Create a story

CREATE2 john.like = mary;
CREATE2 mary.like = john;
CREATE2 (john.like=mary).because = (mary.like=john);
CREATE2 mary.bite = r2d2 _at_before = breakfast;
CREATE2 r2d2.hit = mary _at_during = lunch; CREATE2 (r2d2.hit=mary _at_during=lunch).because = (mary.bite=r2d2 _at_before=breakfast);
CREATE2 john.reboot = r2d2 _at_after = dinner; CREATE2 (john.reboot=r2d2 _at_after=dinner).because = (r2d2.hit=mary _at_during=lunch);

// Queries

// What did mary bite?
// Finds r2d2.

SELECT2 mary.bite = %;

// What hit mary?
// Finds r2d2.

SELECT2 %.hit = mary;

// What did r2d2 do to mary?
// Finds hit
SELECT2 r2d2.% = mary;

// What kind of thing likes john?
// Finds horse (not mary).
SELECT2 %.cls=thing & %.inst=(%.like=john);

// Why did r2d2 hit mary?
// Finds mary.bite=r2d2 before breakfast.
SELECT2 (r2d2.hit=mary).because = %;

// What did john do to r2d2 after dinner?
// Finds reboot.
SELECT2 john.%=r2d2 _at_after=dinner; Received on Thu Nov 11 2004 - 18:26:34 CET

Original text of this message