| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: Network Example: Sibling of Opposite Gender
Tonkuma, thanks for all your effort. You are in a class of people that
includes the likes of Hugo Kornelis, Nick Malik and mAsterdam. I
claimed the "Siblings of Opposite Build" Example (shown below) was
unsolvable systematically in RM/RMDB. You have certainly showed it is
neither impossible or impractical. Whether it is systematic according
to RM, I will leave open for discussion.
Suppose Adam(30) has children named John(tall), Mary(short), Bob(fat), Sue(short/thin), Adam(10). Builds tall/short and fat/thin are opposites. Compose 4 queries (shown below), without explicitly referring to John's parent (Adam), John's build (tall) or relationships between builds in last query:
Below I have summarized/abbreviated the RMDB and dbd solutions to make them easier to compare. See earlier posts for details:
Sibling.person
id name age
1, 'adam', 30 2, 'john', NULL 4, 'mary', NULL 8, 'bob', NULL 9, 'sue', NULL
Sibling.link
parent child
1, 2 1, 4 1, 8 1, 9 1, 10
Sibling.build
'tall' 'athletic' 'petite' 'short' 'thin' 'fat'
Sibling.person_build
id build
2, 'tall' 4, 'short' 8, 'fat' 9, 'short' 9, 'thin'
Sibling.relationship
id verb
1, 'opposite'
Sibling.relation_value
id source target
1, 'tall', 'short' 1, 'short', 'tall' 1, 'fat', 'thin' 1, 'thin', 'fat' ------------------------------------------------------QUERY 1) Find John's siblings.
(!= (and (get person instance *)
(get (get * child john) child *)) john)
SELECT sibling.id, sibling.name AS "john's sibling" FROM Sibling.person john
, Sibling.link k_j
, Sibling.link k_s
, Sibling.person sibling
WHERE john.name = 'john' AND k_j.child = john.id AND k_j.parent = k_s.parent
(!= (and (get person instance *)
(get * build fat)
(get (get * child john) child *))
john)
SELECT sibling.name AS "fat siblings" FROM Sibling.person john
, Sibling.link k_j
, Sibling.link k_s
, Sibling.person_build sib_bld
, Sibling.person sibling
WHERE john.name = 'john' AND k_j.child = john.id AND k_j.parent = k_s.parent AND sib_bld.id = k_s.child
(!= (and (get person instance *)
(get * build (get (get john build *) opposite *))
(get (get * child john) child *))
john)
SELECT sibling.name AS "opposite build"
FROM Sibling.person john
, Sibling.person_build john_bld
, Sibling.link k_j
, Sibling.link k_s
, Sibling.person_build sib_bld
, Sibling.person sibling
WHERE john.name = 'john' AND john_bld.id = john.id AND k_j.child = john.id
(!= (and (get person instance *)
(get * build (get (get john build *) opposite *))
(get (get * child john) child *))
john)
SELECT answer.name AS "Bob's bld same as john & mary"
FROM Sibling.person john
, Sibling.person_build john_bld
, Sibling.person mary
, Sibling.person_build mary_bld
, Sibling.person bob
, Sibling.person_build bob_bld
, Sibling.person answer
, Sibling.person_build answer_bld
WHERE john.name = 'john'
AND mary.name = 'mary'
AND bob.name = 'bob'
AND john_bld.id = john.id
bob_bld.build, answer_bld.build) = 'Y'
AND answer.id = answer_bld.id;
CREATE FUNCTION find_verb (inSource VARCHAR(10), inTarget VARCHAR(10))
RETURNS VARCHAR(16)
LANGUAGE SQL
READS SQL DATA
RETURN (SELECT verb
FROM Sibling.relationship rs
, Sibling.relation_value rv
WHERE rv.id = rs.id
AND rv.source = inSource
AND rv.target = inTarget);
CREATE FUNCTION relationship
(inVerb VARCHAR(16), inSource VARCHAR(10), inTarget
VARCHAR(10))
FROM Sibling.relationship rs
, Sibling.relation_value rv
WHERE rs.verb = inVerb
AND rv.id = rs.id
AND rv.source = inSource
AND rv.target = inTarget)
,'N');
> Why is it necessary new sample? Extension to original sample will be better. It will demonstrate extendability and flexibility of dbd.
The updated "Siblings of Opposite Build" allowed each person's attribute to have multiple values and opposite values could not be determined by using the NOT function. I started a new example, instead of updating the old example, to make it easier to follow and compare.
> Neo should first show us dbd's documents like Description and/or User's Guide to let us understand general concept, language elements, terminology, basic syntax, etc. (I hope also he provide us Language reference Like "SQL Reference" of Oracle or DB2.) After that, he can show us samples to let us better understanding of dbd's capability.
Currently, the following is available:
Terminology: www.dbfordummies.com/basic/terminology.asp
General Concepts: www.dbfordummies.com/basic/thing.asp
Basic Syntax: www.dbfordummies.com/NLI/
www.dbfordummies.com/NLI/expression.asp
Language Elements: www.dbfordummies.com/NLI/function.asp
Examples: www.dbfordummies.com/example/default.asp
Sibling Example: www.dbfordummies.com/example/ex120.asp
> I searched dbd on Google. But, I couldn't check all of serach result, Because, there are too many DBD. Most of them related interface to RDB or related to genes.
For old posts, search xdb, xrdb and dbd in comp.databases.theory, comp.databases.object, comp.databases and comp.object.
> His sample always source code only. No result of execution showed (sometimes, he included in comment "(; Get somrthing".).
When an expression (ie get person instance *) is executed from dbd's GUI, the tree view automatically expands and highlights each result step-by-step (ie john, mary, etc), even if they are 70-levels deep as in the Biological Taxonomy which includes approximately 35,000 entries. When an expression is executed from dbd's API, a cursor allows one to scroll thru the result set.
> So, I suspect that dbd is still in concept level or at the best general design level ... and hopefully he supply executable code (even alpha version is welcome).
Beta: www.dbfordummies.com/download/default.asp Received on Sun Jan 07 2007 - 19:47:46 CST
![]() |
![]() |