From: | D(dot)C(dot) <coughlandesmond(at)yahoo(dot)fr> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Subject: | REFERENCES to foreign tables |
Date: | 2005-05-21 12:08:32 |
Message-ID: | 1b8e18687ec78f05325ef462c2ec440e@yahoo.fr |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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.
From | Date | Subject | |
---|---|---|---|
Next Message | John DeSoi | 2005-05-21 12:27:33 | Re: REFERENCES to foreign tables |
Previous Message | Adam Bogacki | 2005-05-21 10:06:39 | postgresql-dump .. catch 22 ? |