S
scion
I have 3 tables - CLIENTS, VENDORS and DOCUMENTS. For the sake of
simplicity, let's say each table has the following fields:
CLIENTS: ClientID, ClientName
VENDORS: VendorID, VendorName
DOCUMENTS: DocumentID, DocumentContent
How would I setup a proper relationship if:
1. The Document may be sent to a Client, but not to a Vendor.
2. The Document may be sent to a Vendor, but not to a Client.
3. The Document may be sent to BOTH a Vendor AND a Client.
Note: The Document MUST be sent to AT LEAST a Vendor or a Client.
Thought this implied a Junction table, but can't figure out how it
would work. I thought about putting the ClientID and VendorID fields
into the Documents table (as foreign keys), but I've read that foreign
keys should always be set to REQUIRED, so as to prevent orphaned
records.
But I can't set BOTH the VendorID and ClientID foreign keys to
REQUIRED, since that would mean that the Document would HAVE to go to
both the Vendor AND the Client.
Am I missing a simple concept? (wouldn't be the first time :-0)
simplicity, let's say each table has the following fields:
CLIENTS: ClientID, ClientName
VENDORS: VendorID, VendorName
DOCUMENTS: DocumentID, DocumentContent
How would I setup a proper relationship if:
1. The Document may be sent to a Client, but not to a Vendor.
2. The Document may be sent to a Vendor, but not to a Client.
3. The Document may be sent to BOTH a Vendor AND a Client.
Note: The Document MUST be sent to AT LEAST a Vendor or a Client.
Thought this implied a Junction table, but can't figure out how it
would work. I thought about putting the ClientID and VendorID fields
into the Documents table (as foreign keys), but I've read that foreign
keys should always be set to REQUIRED, so as to prevent orphaned
records.
But I can't set BOTH the VendorID and ClientID foreign keys to
REQUIRED, since that would mean that the Document would HAVE to go to
both the Vendor AND the Client.
Am I missing a simple concept? (wouldn't be the first time :-0)