X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9F116D81B9 for ; Fri, 14 Oct 2005 12:53:58 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 27181-02 for ; Fri, 14 Oct 2005 15:53:55 +0000 (GMT) Received: from hotmail.com (bay103-f36.bay103.hotmail.com [65.54.174.46]) by svr1.postgresql.org (Postfix) with ESMTP id 7D0E4D95B8 for ; Fri, 14 Oct 2005 12:53:55 -0300 (ADT) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Fri, 14 Oct 2005 08:53:54 -0700 Message-ID: Received: from 65.54.174.200 by by103fd.bay103.hotmail.msn.com with HTTP; Fri, 14 Oct 2005 15:53:54 GMT X-Originating-IP: [66.227.111.66] X-Originating-Email: [russellsimpkins@hotmail.com] X-Sender: russellsimpkins@hotmail.com In-Reply-To: <20051014124334.GC19930@clarisys.fr> From: "Russell Simpkins" To: david.pradier@clarisys.fr Cc: pgsql-sql@postgresql.org Subject: Re: Design problem : using the same primary keys for inherited objects. Date: Fri, 14 Oct 2005 11:53:54 -0400 Mime-Version: 1.0 Content-Type: text/plain; format=flowed X-OriginalArrivalTime: 14 Oct 2005 15:53:54.0908 (UTC) FILETIME=[7AF0E1C0:01C5D0D7] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.895 required=5 tests=[AWL=0.145, DNS_FROM_RFC_ABUSE=0.374, DNS_FROM_RFC_POST=1.376, MSGID_FROM_MTA_HEADER=0] X-Spam-Level: * X-Archive-Number: 200510/167 X-Sequence-Number: 23020 >Thanks Russ, but well... >It doesn't help me a lot. Our needs seem to allow that we use an id as >primary key and foreign key at the same time. >What i fear more is that it be against a good database design practice, >because leading to potential problems. > >I give a clearer example : > >CREATE TABLE actor ( >id_actor serial PRIMARY KEY, >arg1 type1, >arg2 type2 >) > >CREATE TABLE person ( >id_person INTEGER PRIMARY KEY REFERENCES actor, >arg3 type3, >arg4 type4 >) > >Don't you think it is a BAD design ? >If it isn't, well, it will expand my database practices. That is perfectly valid. Only, I would argue that an actor is a person. What I was offering was dealing with issues where more then one actor could be the same person. Given your design, a person could only be one actor. If that is true, no more discussion is needed. If that is not true, then one way to deal with that is to make compound primary keys in your actor table. table person ( person_id serial primary key, name varchar(20)); table actor( person_id foreign key references person, role varchar(20), primary key ( person_id, role ) ); would then allow a person to be more then on actor based on role.