Answer the question
In order to leave comments, you need to log in
What is the best way to implement one-to-many dynamic data?
I have a laravel project and a postersql db. I would like a hint on how best to implement.
There is a branch and it has an office. In principle, these data do not change so often. That is, the user can add or remove offices from the branch. Approximately the editing form looks something like this
. The relationship is implemented one-to-many hasMany.
There are no questions about creating, but there are questions about editing. 3 options come to my mind.
1 option is for me to store the room column in the branch table and this json format and store information about the room there like name and that's it, you can do something else but it doesn't matter. There then it will be like in the schedule to give these rooms so that they are fixed. but I don't think this will be a problem. And accordingly, when the user edits, the room is updated completely
The 2nd option is to delete the entries in the rooms associated with this branch when updating and add again. Just how much does it cost?
Option 3 is to take a record to watch there is such a text name if not then update. But it seems to me that this option is much less productive and not of high quality than the other two
. Or maybe there are some other ways to implement this design?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question