Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id BE6862E0048 for ; Thu, 22 Nov 2007 07:02:14 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 02536-02 for ; Thu, 22 Nov 2007 07:02:02 -0400 (AST) Received: from rv-out-0910.google.com (rv-out-0910.google.com [209.85.198.184]) by postgresql.org (Postfix) with ESMTP id 55BBA2E0044 for ; Thu, 22 Nov 2007 07:02:05 -0400 (AST) Received: by rv-out-0910.google.com with SMTP id l15so2390302rvb for ; Thu, 22 Nov 2007 03:02:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; bh=I4PyhmcOCGRVTtBNHSKST0p5DMdaJbE6GZDZk84CDq8=; b=HinPjiAh7tovzeHYjD2W5LLeNTFSLO5HjUycYn9ZYYYh7aDBEehTjlviM0iJhp6TMzpObk+ktsHYHnpKAJjU/yE4kAJM01WGN6FebZgvGixEg50v0FP12kZQb2u/YgRIsiHRfZASTNSmcsxXK4tBrB2Z2AWC0m3Wpx3e/+Mb5E8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=RJnqAfg69M6/4NS13cbIJnc+OZVX5GE69qP+rbfHK9j0TTjBKaCBbkpXmCyLD7oBEsOl93FXqnq8LTPlcpDw5uK3BZaTZrLl0OM7z6jcrlnLWvYGGJNyM2X6v2aCpkPepVZj1dxsf0aWEEMBugQ3egonGN68RGqRlIGB3sTbnho= Received: by 10.140.201.1 with SMTP id y1mr3841284rvf.1195729320005; Thu, 22 Nov 2007 03:02:00 -0800 (PST) Received: by 10.141.115.20 with HTTP; Thu, 22 Nov 2007 03:01:59 -0800 (PST) Message-ID: <99d8c2310711220301p57c9b7c5i4620a7e658d13b7d@mail.gmail.com> Date: Thu, 22 Nov 2007 12:01:59 +0100 From: "Daniel \"bodom_lx\" Graziotin" To: pgsql-sql@postgresql.org Subject: How to have a unique primary key on two tables MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200711/110 X-Sequence-Number: 29638 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