I'm working on intellecual property management system, where I have 2 tables in database - trademark and design.
Then I have such thing as opposition. This means, if someone else has trademark or design, that looks like our's clients one, manager can create new opposition.
For example, I have 3 tables:
trademark:
id
name
design:
id
name
oppostion:
id
name
object_id
object_table
I don't know, to what table opposition is related, but I should have a possibility to make such kind of query:
SELECT id, name, opposition_object.name FROM opposition
LEFT JOIN (trademark|design) as opposition_object on opposition.object_id = (trademark|design).id
First, I thought about storing table name as object_table column of opposition table, but then I realised I don't know if it will be possible to query table name and, first of all, it's defenitely a bad design.
But I got strucked here and nothing comes to my mind. So does anyone have any ideas how to handle it?