I have:
Table Review
with column item_id
(not pk)
Table Product
with column id
(pk)
Table Business
with column id
(pk)
Relationships:
Review.item_id
references Product.id
Review.item_id
references Business.id
What is the syntax in MySQL for one column field to reference IDs from two different tables?
My research lead me to believe you cannot have one foreign key reference two different tables. My conclusions so far (based on links provided below):
- Use a foreign key without a foreign key constraint
- Use field to reference other records, but do not create a foreign key constraint
- Polymorphic Associations. The foreign key may reference rows in any of several related tables.
- One foreign key can reference only one table
These conclusions seem logical to me, but I can't figure out the syntax.
links:
MYSQL - One Column Referenced to Multiple Table
Is it possible to reference one column as multiple foreign keys?