Answer the question
In order to leave comments, you need to log in
How to use relationships when there are many entities?
Dear, tell me how to implement it correctly.
There are 2 entities: Deals, Tasks. They need to attach halyards.
It was decided to use 1 table with a link to the entity.
The table has the following fields:
id,
component('deal' or 'task', i.e. an entity pointer),
item_id (ID of the record itself, whether it's a deal or a task)
And then the file information fields.
Now tell me how to use relationships in such a table?
I understand that you can choose the required File::find and so on, but I would like, for example, to delete the transaction and the files to be deleted.
Answer the question
In order to leave comments, you need to log in
select something from table1 as t
INNER JOIN сделки as s ON s.id = t.itemId AND t.component = 'сделки'
INNER JOIN сущности as s1 ON s1.id = t.itemId AND t.component = 'сущности'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question