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 68978D8EC4 for ; Fri, 14 Oct 2005 08:18:08 -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 50899-10 for ; Fri, 14 Oct 2005 11:17:59 +0000 (GMT) Received: from hotmail.com (bay103-dav15.bay103.hotmail.com [65.54.174.87]) by svr1.postgresql.org (Postfix) with ESMTP id 444A3D8D4A for ; Fri, 14 Oct 2005 08:18:01 -0300 (ADT) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Fri, 14 Oct 2005 04:18:04 -0700 Message-ID: Received: from 69.177.145.5 by BAY103-DAV15.phx.gbl with DAV; Fri, 14 Oct 2005 11:18:03 +0000 X-Originating-IP: [69.177.145.5] X-Originating-Email: [russellsimpkins@hotmail.com] X-Sender: russellsimpkins@hotmail.com From: "Russell Simpkins" To: "David Pradier" , References: <20051014091829.GB19930@clarisys.fr> Subject: Re: Design problemi : using the same primary keys for inherited objects. Date: Fri, 14 Oct 2005 07:18:10 -0400 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0048_01C5D08F.6ECB5FD0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-OriginalArrivalTime: 14 Oct 2005 11:18:04.0163 (UTC) FILETIME=[F1ED9D30:01C5D0B0] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=4.844 required=5 tests=[DNS_FROM_RFC_ABUSE=0.374, DNS_FROM_RFC_POST=1.376, FORGED_MUA_OUTLOOK=3.037, HTML_30_40=0.056, HTML_MESSAGE=0.001, MSGID_FROM_MTA_HEADER=0] X-Spam-Level: **** X-Archive-Number: 200510/158 X-Sequence-Number: 23011 This is a multi-part message in MIME format. ------=_NextPart_000_0048_01C5D08F.6ECB5FD0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable ----- Original Message -----=20 i've got a strange design question to ask you. It's something I couldn't answer to while feeling confusely it was an absolutely BAD thing to do. For our application, we have developed our own framework which sits on top of PostgreSQL. It uses object programming and implements heritage. Inherited objects use heritage links in the framework and relation = links in PostgreSQL (Search me why it doesn't use heritage in PostgreSQL = !?). I've got this thing : An object A inherits from an object B, which inherits from a object C, which inherits from an object D. One of my colleagues proposed that we don't use serial (integer + sequence) primary keys for these objects, but that we use the very = same integer primary keys. That is : the instance A would use the id 12343, and the instance B = the same id 12343 and the instance C the same id 12343 and the D instance = the same id 12343. It's possible as two instances of an object never inherit from a same instance of another object. The id seems to me absolutely bad, but I wouldn't know how to phrase why. Any suggestion ? Thanks in advance, David. Most of the inheritance i've seen done in databases retain the parent = primary as a foreign key and a primary key. That being said, only you = and your team can decide if more than one object will extend a base = class. If you were doing something more like this person -> sweepstakes entry to model a sweepsakes entry is a person, and you allow a person to enter = a sweepstakes more than once, but to enter a contest the user must = provide a unique email address, then you could not just use a foreign = key as the primary key in sweepstakes, since the primary key would = disallow multiple entries in sweepstakes entry, you would then use a = serial data type in both person and sweepstakes along with the foriegn = key in sweepstakes from person. The answer depends on the need. Hope that helps. Russ ------=_NextPart_000_0048_01C5D08F.6ECB5FD0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
----- Original Message -----
i've got=20 a strange design question to ask you.
It's something I couldn't = answer to=20 while feeling confusely it was an
absolutely BAD thing to = do.

For=20 our application, we have developed our own framework which sits = on
top of=20 PostgreSQL. It uses object programming and implements = heritage.
Inherited=20 objects use heritage links in the framework and relation links
in=20 PostgreSQL (Search me why it doesn't use heritage in PostgreSQL=20 !?).

I've got this thing :
An object A inherits from an = object B,=20 which inherits from a object C,
which inherits from an object = D.
One of=20 my colleagues proposed that we don't use serial (integer = +
sequence)=20 primary keys for these objects, but that we use the very = same
integer=20 primary keys.
That is : the instance A would use the id 12343, and = the=20 instance B the
same id 12343 and the instance C the same id 12343 = and the D=20 instance the
same id 12343.

It's possible as two instances = of an=20 object never inherit from a same
instance of another = object.

The id=20 seems to me absolutely bad, but I wouldn't know how to=20 phrase
why.

Any suggestion ?

Thanks in=20 advance,
David.
Most of the inheritance i've seen done = in databases=20 retain the parent primary as a foreign key and a primary key. That = being=20 said, only you and your team can decide if more than one object will = extend a=20 base class. If you were doing something more like this
 
person -> sweepstakes = entry
 
to model a sweepsakes entry is a = person, and=20 you allow a person to enter a sweepstakes more than once, but to enter a = contest=20 the user must provide a unique email address, then you could not just = use a=20 foreign key as the primary key in sweepstakes, since the primary key = would=20 disallow multiple entries in sweepstakes entry, you would then use = a serial=20 data type in both person and sweepstakes along with the foriegn key in=20 sweepstakes from person.
 
The answer depends on the need. Hope = that=20 helps.
 
Russ
------=_NextPart_000_0048_01C5D08F.6ECB5FD0--