REFERENCES to foreign tables - Mailing list pgsql-novice

From D.C.
Subject REFERENCES to foreign tables
Date
Msg-id 1b8e18687ec78f05325ef462c2ec440e@yahoo.fr
Whole thread Raw
Responses Re: REFERENCES to foreign tables  (John DeSoi <desoi@pgedit.com>)
Re: REFERENCES to foreign tables  (Michael Glaesemann <grzm@myrealbox.com>)
List pgsql-novice
Hi (not sure if the Subject: field is correct, but here goes ..),

I'm trying to build some more complexity into the db that I mentioned
recently.  If in the 'clients' table, I have

client_id int NOT NULL PRIMARY KEY CHECK (client_id > 0)
name varchar(50) NOT NULL
[...]

... and in the 'sales' table, I have ...

sale_id int NOT NULL PRIMARY KEY CHECK (sale_id > 0)
sold_to INT NOT NULL REFERENCES clients (client_id)
[...]

So when a sale is entered, postgreSQL keeps a record of who it was sold
to.  Now what happens if I want to delete the client who bought the
item in question ?  I'm going to have a 'sales' table that references a
buyer who no longer exists (in db terms, naturally).  I wondered aloud
(talking to the wall, sort of) if I could reference clients.client_id
to sales.sale_id, but wouldn't that stop my adding a client who hasn't
yet made a purchase ?

Thanks in advance.

D.



pgsql-novice by date:

Previous
From: Adam Bogacki
Date:
Subject: postgresql-dump .. catch 22 ?
Next
From: John DeSoi
Date:
Subject: Re: REFERENCES to foreign tables