I understand that bulk relations update is not possible by reading other topics in this area and have watched some of Mark’s videos regarding the best practice around this topic. However, I would love some input into my particular setup.
I have 4 tables:
- Jobs
- Agencies
- Clients
- Workers
One job relates to 1 agency, 1 client & 1 worker.
I have a requirement to be able to bulk add 50+ jobs in one go, where they are all from the same agency + client (i.e. workers relations will be left blank for now).
Approach 1
Jobs is “parent” with relations to agencies, clients, workers
However, this approach will mean that when I add 50 jobs, I will need to do the following:
- 50 deepsave or transactions API call, one for each job.
Approach 2
Agencies, Clients and Workers tables has a relation column pointing to Jobs
When adding 50 jobs, I will do the following:
- 1 x Bulk Create for Jobs
- 1 x Add relations in Agencies
- 1 x Add relations in Clients
- 1 x Add relations in Workers
Can I ask what’s best practice between approach 1 & 2? Approach 2 seems more optimal if users often add 5+ jobs in one go. However, in the 1:N relations column in Agencies, Clients and Workers pointing to Jobs, it will then have 1000s of relations.
Is there any performance considerations, or any other considerations that would say Approach 1 is more optimal?
Many thanks in advanced!