| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: MultiValue Databases
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.
// 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 #.
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"
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 Thu Jun 09 2005 - 17:24:45 CDT
![]() |
![]() |