I have three tables that contain information for an invoicing system. One table, InvoiceImage, contains image information with multiple records for each invoice and the other two tables, InvoicePending and Invoices, are for pending and approved invoices.
As it occurs now I have to create the initial invoice record in InvoicePending then associate image records in InvoiceImage to said invoice using columns named InvoiceID (reference to the PK in the invoice table) and TableID (signifies which invoice table to use).
When the invoice is approved I have to trensfer the pending invoice from InvoicePending into Invoices and update the InvoiceID & TableID columns in the InvoiceImage to point to the new location.
What I need to know is if there is a way to define a relationship between the InvoiceID columns of InvoiceImage & InvoicePending and then InvoiceImage & Invoices seperatley based on the value in InvoiceImage.TableID.
I understand that under normal circumstances there should only be one invoice table with a status column which would solve this problem very easily BUT certain political issues coupled with design concerns preclude that from being a possibility.
As it occurs now I have to create the initial invoice record in InvoicePending then associate image records in InvoiceImage to said invoice using columns named InvoiceID (reference to the PK in the invoice table) and TableID (signifies which invoice table to use).
When the invoice is approved I have to trensfer the pending invoice from InvoicePending into Invoices and update the InvoiceID & TableID columns in the InvoiceImage to point to the new location.
What I need to know is if there is a way to define a relationship between the InvoiceID columns of InvoiceImage & InvoicePending and then InvoiceImage & Invoices seperatley based on the value in InvoiceImage.TableID.
I understand that under normal circumstances there should only be one invoice table with a status column which would solve this problem very easily BUT certain political issues coupled with design concerns preclude that from being a possibility.