Thread: OID

OID

From
Jamie Deppeler
Date:
Hi,

Im planning on using OID for referencing in certain part of the system
i am building as in this case using normal pk -> fk would be
inefficient as i have to have once table reference multi tables, but i
have concerns that if a Database is exported and reconstructed the
OID's will change making referencing impossible.

Any ideas would helpful
--


Jamie
Deppeler
<font
 face="Verdana, Helvetica" size="2">Database Administrator
<font
 face="Verdana, Helvetica">
Cormoran
Communication

Do It Once!

<font
 face="Verdana, Helvetica" size="2">
<font color="#800080"
 face="Verdana, Helvetica">

Re: OID

From
Martijn van Oosterhout
Date:
Firstly, please don't send email in only HTML, it tends to get them
marked as spam.

> SPAM: Hit! (3.2 points)  HTML-only mail, with no text version

Anyway, as to your question:

> Im planning on using OID for referencing in certain part of the
> system i am building as in this case using normal pk -> fk would
> be inefficient as i have to have once table reference multi tables,
> but i have concerns that if a Database is exported and reconstructed
> the OID's will change making referencing impossible.<br>

There is no use of OIDs that cannot be better served by sequences. I
presume the issue is that in your multiple tables you may have the same
PK appear. Well, there is no reason why a sequence should be tied to a
single table. For example:

CREATE SEQUENCE my_global_counter;

CREATE table_1 ( id int4 default nextval('my_global_counter') primary key, ...
CREATE table_2 ( id int4 default nextval('my_global_counter') primary key, ...
CREATE table_3 ( id int4 default nextval('my_global_counter') primary key, ...

Is this what you're looking for?
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

Attachment