Can a field be a primary key as well as a foreign key?

From: Andrew Snow <andrew(at)modulus(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: Can a field be a primary key as well as a foreign key?
Date: 2002-03-12 04:44:09
Message-ID: 20020312154409.B397@esper.modulus.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Can anyone see any problem with the following, practice?

CREATE TABLE parent (
foo SERIAL PRIMARY KEY
);

CREATE TABLE child (
foo INTEGER PRIMARY KEY REFERENCES parent ON DELETE CASCADE,
bar TEXT
);

CREATE TABLE subchild (
foo INTEGER PRIMARY KEY REFERENCES child ON DELETE CASCADE,
bar2 TEXT
);

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Francisco Reyes 2002-03-12 05:46:46 Re: spanish characters in postgresql
Previous Message Tom Lane 2002-03-12 02:23:54 Re: pg_toast table growth out of control