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?
No you can’t. One option is to first generalise Employee/Customer as “Party” or “Stakeholder”.
I.e.
Then Contact would reference Party.