table and some other tables?
For example, Having a table with columns,
First column to specify the relation's other end table, and another column for out foreign key which based on the first column, it's target changes
Like first column specifies if the this row is about a product or service
There are 2 other tables for products and services, if the first column's data is product, then the second column is linked to products table id, if first column's data is service, then the second column is linked to services table id
Is it possible? Is it okey or are there better practices for doing such a thing?
er...this feels very wrong
It's definitely possible. Some ORMs also do it the way you mention it. But if your relation is one-to-one, you can solve it by placing your foreign key on the other tables.
Обсуждают сегодня