From: | Hélder M(dot) Vieira <hmv(at)mail(dot)telepac(dot)pt> |
---|---|
To: | <pgsql-performance(at)postgresql(dot)org> |
Subject: | Re: Faster db architecture for a twisted table. |
Date: | 2005-12-04 01:33:13 |
Message-ID: | 005501c5f872$b1ce1380$580bfea9@hmv02 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
----- Original Message -----
From: "Andreas Pflug" <pgadmin(at)pse-consulting(dot)de>
> Create a table "sibling" with parent_id, sibling_id and appropriate FKs,
> allowing the model to reflect the relation. At the same time, you can drop
> "mother" and "father", because this relation is covered too
Something like a table describing relationships and a table reflecting
relationships from both sides, I guess:
create table relationship_type
(
relationship_type_id serial,
relationship_type_description varchar(20)
)
populated with values such as:
1 Child_of
2 Father_of
3 Brother_of
4 Sister_of
...
And then
create table person_relationships
(
source_person_id int4,
relationship_type_id int4,
target_person_id int4
)
populated with values such as:
1 1 2 (person 1 is child of person 2)
2 2 1 (person 2 is father of person 1)
...
It requires a careful maintenance, as almost all (I'd stick with ALL)
relationships will require a person to appear twice (as source and as
target), but flexible and easy to query.
Helder M. Vieira
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas F. O'Connell | 2005-12-04 06:40:01 | Re: Very slow queries - please help |
Previous Message | David Lang | 2005-12-04 01:17:03 | Re: Database restore speed |