Skip site navigation (1) Skip section navigation (2)

Re: Multiple Columns Keys - Good or Bad idea?

From: Ryan Ho <ryanho(at)cyberronins(dot)com>
To: Rob Brown-Bayliss <rob(at)ZOOstation(dot)cc>, PGSQL Novice List <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Multiple Columns Keys - Good or Bad idea?
Date: 2001-06-11 08:48:26
Message-ID: 01061116482600.01482@ignis.ajiang.com (view raw or flat)
Thread:
Lists: pgsql-novice
On Monday 11 June 2001 16:09, Rob Brown-Bayliss wrote:
> Hi, this is not really a postgres question, more of a design question so
> I hope no one minds...
>
> I have to intergrate data from several sites, updates and new data, etc
> etc, so I have come up with the following idea:
>
> all tables will have a sequence and location column, these two columns
> are the primary key.  each site has it's own location number and own
> sequence inserted by default.
>
> Is this a good idea?  would it be better to have just the sequence as
> primary key, and make sure each site has a different sequence (ie: site
> one starting at 1, site 2 starting at 10,000,000)
>
> The second idea seems a bit kludgy to me, but if I go the first way I
> have two have two cloumns as links in each table, you know SELECT * FROM
> foo WHERE key1=77 and key2=4
>
> Stuck and awaiting help...
>
> Thanks

I'd go for the first method. If you need to refer to the integrated table 
often (e.g. as foreign key in other tables), it may be a good idea to give it 
a new sequence. So the integrated table will have location, the sequence 
number at the remote site, and a unique local sequence number.

Regards
-- 
Ho Siaw Ping, Ryan
IT Consultant
Database / Web Apps

In response to

Responses

pgsql-novice by date

Next:From: Michael RothDate: 2001-06-11 16:14:43
Subject: FATAL ERROR
Previous:From: Rob Brown-BaylissDate: 2001-06-11 08:09:54
Subject: Multiple Columns Keys - Good or Bad idea?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group