Re: How to find Brothers and Sisters?
Date: 3 Dec 2006 13:00:33 -0800
Message-ID: <1165179633.075956.234970_at_f1g2000cwa.googlegroups.com>
Neo a écrit :
> > This view gets the id of the parent for a specific sibling...
> > create view as Q_B
> > SELECT DISTINCT person.id
> > FROM link INNER JOIN person ON link.child = person.id
> > WHERE (((person.name)='John'))
>
> To get John's parent's id, shouldn't the query select link.parent
> instead of person.id?
>
> > This view gets all sibling's for a specific parent id then restricts name ...
> > select P2.name from person P2
> > inner join link
> > on Q_B B
> > on P2.parent = B.id
> > where P2.name <> 'John'
>
> P2 is an alias for person table, so P2.parent is really person.parent,
> but the person table doesn't have a parent field (link table does)?
> Also is joining person and link tables based on Q_B valid?
Setting up hierarchies on a relational perspective is not a difficult
thing to do. Putting a parent attribute in person does not allow to
have a 1:0 cardinality between person and sibling , a common error
done...A person does not nessecarily have a parent while may or may not
have a sibling...In other words there is only one correct way to do
that RM wise...
Received on Sun Dec 03 2006 - 22:00:33 CET