pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: lcampos@ics.uci.edu
To: pgsql-sql@postgresql.org
Subject: primary/foreigner keys
Date: 21 Nov 2001 16:11:04 -0800
Message-ID: <5fa15e5f.0111211611.c4dd97b@posting.google.com> (raw)

Hi,
I am trying to do the following:
CREATE TABLE Customer (
customer_id SERIAL PRIMARY KEY;
account_id INTEGER UNIQUE REFERENCES Account DEFERRABLE);

CREATE TABLE Account (
account_id SERIAL PRIMARY KEY,
customer_leader_id INTEGER UNIQUE REFERENCES Customer DEFERRABLE);

Description:
I am trying to create two tables where several customers can belong to
an account and each account has a customer leader.
This involves having each tables primary keys to be the foreigner key
in the other table. (other solutions are welcome)

Problem:
First I can not create either table because the other is not known.
I tried even within a BEGIN; table creation; commit;
Secondly If I succeed how do I INSERT values into the tables?

I am sure someone has already faced such a problem, so there must be a
solution out there but I could not find it in the postgresql
documention.

Thank you for your help,
Miguel



view thread (2+ messages)  latest in thread

Message-ID: <5fa15e5f.0111211611.c4dd97b@posting.google.com>
Permalink:  ../5fa15e5f.0111211611.c4dd97b@posting.google.com/
Also on:    postgresql.org/message-id/5fa15e5f.0111211611.c4dd97b@posting.google.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: lcampos@ics.uci.edu
  Subject: Re: primary/foreigner keys
  In-Reply-To: <5fa15e5f.0111211611.c4dd97b@posting.google.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox