Re: question about which column(s) are the right foreign key

From: Markus Bertheau <twanger(at)bluetwanger(dot)de>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: question about which column(s) are the right foreign key
Date: 2004-06-25 14:18:01
Message-ID: 1088173080.3189.8.camel@teetnang
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

В Пнд, 21.06.2004, в 06:57, Josh Berkus пишет:
> Markus,
>
> > I have objects in my database, and they have an object id generated with
> > a sequence. Then I have object versions. The ids of object versions need
> > to be unique only within one object id. But for simplicity they're
> > generated with a sequence, too.
> >
> > Now I want to reference an object version. I can use just the object
> > version id, because it "happens" to be globally unique. Conceptually
> > though, I should use the object's id and its version's id.
> >
> > Now redundancy is Not Good™, so I wonder which way is the Right One™.
> >
>
> Well, conceptually, you should have generated a numerical version id for each
> object version which would have told you the sequence in which that version
> was created, i.e. version #1 of object 23421, version #2 of object 23421,
> etc. This can be automated a number of ways, although it does require
> locking the object during a version save.
>
> The problem with the setup you have now is that you have an Object ID, which
> doesn't intrinsically mean anything, and an Object Version ID, which also
> doesn't tell you anything about the object or the version. If you want to
> keep information about which "edition" of an object this particular
> object-version is, you'll have to add a column -- which will then make the
> object-version id redundant, since the table will then have two keys.
>
> That's "the Right One™"

Thanks. That really did provide the neccessary insight.

--
Markus Bertheau <twanger(at)bluetwanger(dot)de>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Markus Bertheau 2004-06-25 15:12:43 Re: question about which column(s) are the right foreign key
Previous Message Przemysław Słupkowski 2004-06-25 13:26:34 Join columns