| From: | Tom <tom(at)vms7(dot)com> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | Having an optional foreign key (ie. sometimes NULL) ? |
| Date: | 2003-03-13 22:58:14 |
| Message-ID: | 1047596316.3e710d1c84742@IMP-3.2 |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Hello,
I have the following tables:
- company (eg. ABC Shipping Inc.)
- product (eg. table, chair, pen, pencil)
- client (eg. Joe's Insurance Company)
and they relate to each other as follows:
- a company has clients (company is a foreign key in client)
- a company sells products (company is a foreign key in client)
which is all well and good until I come to one specification in my design
document which says that "some products will only be available to a single
client whereas other products will be available to all clients".
I thought the best way to get around this would be to have the client as a
foreign key in products but for products available to all clients this won't
work.
Can someone advise how I can overcome this?
Thanks, Tom.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2003-03-13 23:00:26 | Re: functional indexes and their costs |
| Previous Message | Jean-Luc Lachance | 2003-03-13 22:36:48 | Re: Function in selection? |