I'm currently implementing CRUD for a project. I have a lot of many-to-many
relationships. Some of them are table1_id, table2_id, and some of them have additional columns (price, amount, etc).
What is the best way to update many-to-many
table: as you can see, there can be some information already along with new data.
Example
t1_id t2_id amount
1 3 15
2 4 50
I'd like to update this info and send some data like : {1,3,15}
, {2,5, 25}
. So i need to update the first line and insert a new line.
I want to create a function (pl/sql) that will take table of records and check whether it's a new record or record for update.
Question
: Are there any better ways to implement this? Are there any patterns to accomplish that goal?