How to have a unique primary key on two tables

From: "Daniel \"bodom_lx\" Graziotin" <daniel(dot)graziotin(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: How to have a unique primary key on two tables
Date: 2007-11-22 11:01:59
Message-ID: 99d8c2310711220301p57c9b7c5i4620a7e658d13b7d@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi everybody,
I need to have a primary key which has to be unique on two tables.
E.g.:

CREATE TABLE first
(
id serial NOT NULL,
testo text,
)

CREATE TABLE second
(
id serial NOT NULL,
testo text,
)

When I insert some text on "first", I would like first.id = second.id
+ 1, and vice versa.
A sort of primary key in common for both tables.

Any hints?
Thank you very much
--
Daniel "bodom_lx" Graziotin
- http://daniel.graziotin.net
- http://daniel.graziotin.net/bodom_lx.asc - GPG public key

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Bart Degryse 2007-11-22 11:11:20 Re: How to have a unique primary key on two tables
Previous Message Richard Broersma Jr 2007-11-22 07:44:47 Bad Schema Design or Useful Trick?