Re: MultiValue Databases

From: Neo <neo55592_at_hotmail.com>
Date: 9 Jun 2005 15:24:45 -0700
Message-ID: <1118355885.279907.72770_at_g43g2000cwa.googlegroups.com>


It seems I have wrongly assumed that had agreed with John's updated schema to handle the new data "John like Mary" and the new query to find the relationship between John and 111-1111. I am now realizing that, unlike John, you would prefer to made some simpler changes to the original RM schema. IMO, John made the correct changes, however let us now proceed as you would have. Below I have consolidate the xrdb and RM scripts. The RM script has my guess of what you would have done instead. If it isn't, please post it explicitly.

  • original xrdb script **************************­***************
    (CREATE type inst *person & dir item it)
    (CREATE type inst *phone#)
    (CREATE person inst *john)
    (CREATE john phone# +111-1111)
    (CREATE john phone# +222-2222)
    (CREATE person inst *mary & it phone# +222-2222)
    (CREATE person inst *bob)
    (SELECT * phone# 111-1111 & * phone# 222-2222) // returns john.

// Additional data/query that was not known when db was first created. // Note: No impact on existing "schema".
(CREATE verb inst *like)
(CREATE john like mary)
(SELECT john * mary) // Query returns like.
(SELECT john * 111-1111) // Query returns phone #.

  • Script for RMDB ******************************­*********** CREATE TABLE phone (int phoneID, char number); INSERT INTO phone (phoneID, number) VALUES (1, "111-1111"); INSERT INTO phone (phoneID, number) VALUES (2, "222-2222");

CREATE TABLE person (int personID, char name);

INSERT INTO person (personID, name) VALUES (1, "john");
INSERT INTO person (personID, name) VALUES (2, "mary");
INSERT INTO person (personID, name) VALUES (3, "bob");

CREATE TABLE person_phone (int personID, int phoneID);

INSERT INTO person_phone (1, 1);
INSERT INTO person_phone (1, 2);
INSERT INTO person_phone (2, 2);

// Find persons with phone# 111-1111 and 222-2222. SELECT person.name
FROM person,

       phone,
       person_phone
WHERE        person.personID = person_phone.personID
AND    person_phone.phoneID  =        phone.phoneID
AND phone.number = "111-1111"
INTERSECT
SELECT person.name
FROM person,
       phone,
       person_phone
WHERE        person.personID = person_phone.personID
AND    person_phone.phoneID  =        phone.phoneID
AND phone.number = "222-2222"

// Neo's guess of Ed's preferred changes to accommodate new data. // I prefer using data-independent IDs to relate things. CREATE TABLE verb (int personID1, char relatedBy, int personID2); INSERT INTO verb values (1, 'likes', 2);

// Find relationship between John and Mary. SELECT verb.relatedBy
FROM person AS person_1 INNER JOIN (person INNER JOIN verb ON person.personID = verb.personID1) ON person_1.personID = verb.personID2 WHERE (((person.name)="John") AND ((person_1.name)="Mary"));

>> Ed, the above RM schema does not support the query to find the >> relationship between John and 111-1111. Please update script.

> Well given that 111-1111 is a PHONE number, > the reference to JOHN is irrelevant (dare I say redundant?)

Suppose John likes the phone# 111-11111 in addition to his phone# being 111-1111 and 222-2222. Below I show how to do it with xrdb. Please post equivalent using your updated RM schema.

(CREATE john like 111-1111)
(SELECT john * 111-1111) // returns phone# and like.


>> SELECT john * mary) // Query returns like. > * operator. What are it's limits?

In xrdb's SELECT, * returns 0 to many things, depending on what is in db. If there are no relationships between John and Mary, no thing is returned. If "John like Mary" is stored in the db, the * returns the thing named "like". If "John like Mary" and "John wife Mary" are in the db, * would first return the thing named "like" then the thing named "wife". Received on Fri Jun 10 2005 - 00:24:45 CEST

Original text of this message