relationship/table design question

From: "Taylor Lewick" <tlewick(at)kc(dot)rr(dot)com>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: relationship/table design question
Date: 2003-12-03 02:44:04
Message-ID: 000f01c3b947$5133c630$c0341a41@taylor
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi all, new to postgresql and I have a question about how to lay out my
database.

I have a database with 4 main tables, organizations, contacts, events,
grants.
My thinking here is that organizations can have contacts, sponsor events,
and sponsor grants, so it is what I would call
the main table. I know how to set up the other tables so that they have a
reference back to org_id. (Basically a foreign key).

How would I handle it (set up in SQL) if I want to be able to assign a
contact to an event. In the event table, would I make a reference back to
the contact table? Can I have more than one foreign key reference per table
going to seperate tables? Finally, can I make the reference constraint be
able to be NULL. Meaning, can I make it so that an event can, but doesn't
have to have a contact assigned to it?

The tables (a simplified view) would look like this...

Organization Table:
org_id
org_name

Contact Table:
contact_id
contact_name

Event Table:
event_id
event_name
reference back to org_id in org table
reference back to contact_id in contact_table but there doesn't have to be a
contact associated with this event.

Thanks,
Taylor

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Byron Amerson 2003-12-03 06:10:10 solaris9 make failure...libpgport.a
Previous Message Gerard Mason 2003-12-02 14:46:41 Abstract base table?