Received: from localhost (unknown [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id BFA402E3BE3 for ; Tue, 11 Dec 2007 15:28:51 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 15580-03-5 for ; Tue, 11 Dec 2007 15:28:44 -0400 (AST) Received: from ns2.instrumentalyst.com (blk-222-55-203.eastlink.ca [24.222.55.203]) by postgresql.org (Postfix) with ESMTP id 515D52E351C for ; Tue, 11 Dec 2007 15:12:50 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) by ns2.instrumentalyst.com (Postfix) with ESMTP id 707F3122 for ; Tue, 11 Dec 2007 15:12:04 -0400 (AST) X-Virus-Scanned: amavisd-new at instrumentalyst.com Received: from ns2.instrumentalyst.com ([127.0.0.1]) by localhost (ns2.instrumentalyst.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xb992xA9ATU0 for ; Tue, 11 Dec 2007 15:11:56 -0400 (AST) Received: from Arjuna.local (rrcs-24-129-176-158.se.biz.rr.com [24.129.176.158]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ns2.instrumentalyst.com (Postfix) with ESMTP id 85630106 for ; Tue, 11 Dec 2007 15:11:56 -0400 (AST) Message-ID: <475EE126.5030302@productivitymedia.com> Date: Tue, 11 Dec 2007 14:12:38 -0500 From: PostgreSQL Admin User-Agent: Thunderbird 2.0.0.6 (Macintosh/20070728) MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Re: Foreign Key for multi PK or design question References: <863ECFDF04C8804ABDF3559D87F157C638E5D9@MAGPTCPEXC02.na.mag-ias.net> <475ED504.7080006@productivitymedia.com> <20071211185330.GA16159@a-kretschmer.de> In-Reply-To: <20071211185330.GA16159@a-kretschmer.de> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.359 tagged_above=0 required=5 tests=AWL=1.207, BAYES_00=-2.599, FH_HOST_ALMOST_IP=1.751 X-Spam-Level: X-Archive-Number: 200712/54 X-Sequence-Number: 29746 This is my layout so far: CREATE TABLE users ( id serial NOT NULL, --question REFERENCES questions(id) ON DELETE CASCADE ## ON REMOVED## ); CREATE TABLE questions ( id serial NOT NULL, questions varchar(450) NOT NULL ); CREATE TABLE answers ( id serial NOT NULL, question_id int REFERENCES questions(id) ON DELETE CASCADE, user_id int REFERENCES users(id) ON DELETE CASCADE, answer varchar(450) NOT NULL, created timestamptz NOT NULL ); Originally I wanted to have a foreign key that would be the pk of the question table. So if the user answered Q2, 5 and 6 - the user.fk would store values 2,5,6 - but I have passed most of logic to the answer table. Does this look correct? or most efficient? J