MySQL Forums
Forum List  »  InnoDB

multiple foreign keys on single field, how to best go about?
Posted by: Paul Carey
Date: November 02, 2008 09:52PM

Hello and thanks for looking,

I'll explain what it is I'm trying to achieve with an example...

I'm trying to record documents that have been produced like the following..

Invoice
invoice_id
...
...

Order
order_id
...
...

DocumentProduced
doc_id
date_printed
type <- A ref to the type of document produced e.g. Quote (1) or Invoice (2), etc
ref_id <- The id of the document e.g. the invoice or quote id

What I'd like to do is set up foreign keys to the tables such as Quote and Invoice on the ref_id field of DocumentProduced as far as I know its only possible to set one foreign key on a field.

Would there be any other way if this is true that it can be done such as constraints or triggers?

Thanks very much in advance

Paul

Options: ReplyQuote


Subject
Views
Written By
Posted
multiple foreign keys on single field, how to best go about?
4744
November 02, 2008 09:52PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.