pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Markus Bertheau <twanger@bluetwanger.de>
To: Josh Berkus <josh@agliodbs.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: question about which column(s) are the right foreign key
Date: Fri, 25 Jun 2004 16:18:01 +0200
Message-ID: <1088173080.3189.8.camel@teetnang> (raw)
In-Reply-To: <200406202157.57676.josh@agliodbs.com>
References: <1087766532.2660.27.camel@teetnang>
	<200406202157.57676.josh@agliodbs.com>

В Пнд, 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@bluetwanger.de>




view thread (4+ messages)  latest in thread

Message-ID: <1088173080.3189.8.camel@teetnang>
Permalink:  ../1088173080.3189.8.camel@teetnang/
Also on:    postgresql.org/message-id/1088173080.3189.8.camel@teetnang

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: twanger@bluetwanger.de, josh@agliodbs.com
  Subject: Re: question about which column(s) are the right foreign key
  In-Reply-To: <1088173080.3189.8.camel@teetnang>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox