referencing multiple tables through a single column in sql
foreign-keys, sql
Solution
No you can't. One option is to first generalise Employee/Customer as "Party" or "Stakeholder". I.e.
TABLE: Party(PK Party_Id,
Name)
TABLE: Employeee(PK Emp_Id REFERENCES Party.Party_Id,
Salary)
TABLE: Customer(PK Cust_Id REFERENCES Party.Party_Id,
CreditRating)
Then Contact would reference Party.
Problem
In SQL can a single column in a table reference multiple tables? E.g. if we have tables `employee` (PK `emp_id, name`) and `customer` (PK `cust_id, name`) Can we have a table `contact` (id references `[employee, customer], number`); Or do we necessarily need to make 2 tables: `contact_cust` (`cust_id` references `customer, number`) and `contact_emp` (`emp_id` references `employee, number`) I know that the second choice would be better even if the first one were possible. I just want to know is the first way possible?