❔ SQL query for multiple data objects
Hello folks, Imagine i have a json array of json objects that i send to an API wich uses a SQL query to INSERT the data into the database.
Each json object in the array contains data that should be pushed into table 1.
every json object also contains a property called parameters that is an Array of objects. each object of this parameters array needs to be inserted into table 2.
Is it normal practice to for example loop over all parameters and execute the SQL query for each item? It feels wrong to do that somehow but then again i dont know what other option there is. Thanks in advance!
6 Replies
Normally you would create a Sql query that inserts many rows at once
Or use some objects/classes/systems from your programming language
but in my case this can't be done right?
I have this data structure:
Why can't it be in one query?
it can, you'd loop over it and construct 1 SQL query string
and then do that 1 sql query
EF Core would make your life way easier with this
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.