X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id DA871D1B590 for ; Wed, 3 Dec 2003 02:44:18 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 46109-02 for ; Tue, 2 Dec 2003 22:43:55 -0400 (AST) Received: from ms-smtp-02.rdc-kc.rr.com (ms-smtp-02.rdc-kc.rr.com [24.94.166.122]) by svr1.postgresql.org (Postfix) with ESMTP id B8FF4D1CCCD for ; Tue, 2 Dec 2003 22:43:46 -0400 (AST) Received: from taylor (CPE-65-26-52-192.kc.rr.com [65.26.52.192]) by ms-smtp-02.rdc-kc.rr.com (8.12.10/8.12.7) with SMTP id hB32hpOg001332 for ; Tue, 2 Dec 2003 20:43:52 -0600 (CST) Message-ID: <001c01c3b947$8cf3cb70$c0341a41@taylor> From: "Taylor Lewick" To: Subject: relationship/table design question Date: Tue, 2 Dec 2003 20:45:45 -0600 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Virus-Scanned: Symantec AntiVirus Scan Engine X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200312/44 X-Sequence-Number: 16210 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.