I am supposed to be shipping out a box with variable contents and tracking this in a database. All of my items (the contents of a box) are different types and require different tables to track their respective pieces of information, although each item type has the same length serial number (i.e. PK are the same datatype). And I have a Boxes table.
So each item has a table (~7 tables) plus the box table. I want to create a BoxContents
table. I tried to make a many-to-many relationship intermediate table with two columns: one for BoxID
and one for ItemBarcode
, where BoxID
is a FK to the PK on the Boxes
table and the ItemBarcode
is a FK to each of the PKs on the Items tables (i.e. I tried to link multiple tables to the same column). Unsurprisingly this didn't work. I tried to insert an item and the FK constraint was violated on all but one of the ItemBarcode
relationships.
How can I construct my relationships to link several types of items to one box in one table? Is this a logical approach? Do you need more information?