P Kishor <[EMAIL PROTECTED]> wrote:
I am modeling entities and their relationships to each other. A
classic network digraph kind of stuff. The entities are organizations
or persons. A person may be associated with none (org type
"unassigned") or one organization, and, of course, an organization may
have none or more persons in it.
I started with
CREATE TABLE orgs (
org_id INTEGER PRIMARY KEY,
.. bunch of org stuff ..
);
CREATE TABLE persons (
person_id INTEGER PRIMARY KEY,
org_id INTEGER -- FK to orgs(org_id)
.. bunch of person stuff ..
);
CREATE TABLE relationships (
rel_id INTEGER PRIMARY KEY,
from_id INTEGER, -- person_id or org_id
to_id INTEGER, -- person_id or org_id
entity_type INTEGER DEFAULT 0, -- 0 is "org", 1 is "person"
relationship TEXT
);
Why do you feel you need this last table at all? All the information is
already available from persons.org_id.
Igor Tandetnik
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------