I think you are referring to the server side.
I'm referring to the client side.
If you model your API in a normalized way. How do you generally approach a situation where the UI needs to affect several entities at once? Do you have denormalized abstractions in your API?
I am a Software Engineer with robust problem-solving skills. Working actively in the tech industry, planning, creating, and designing beautiful business software
Well, let's say we have multiple entities, each of which can be standalone entities (no foreign keys) but are referenced in some pivot tables for example. And if I had a situation where the FE sends me a request with all necessary data to create and populate multiple entities, if validation passes, we could first create entities that are not dependable, and after that, we can create all other dependencies. If for some reason it breaks, we can always roll back what we previously created. It is a bit more complex than this, but I would really like to know how do you handle N+1 problems?
What I do is I have denormalized abstractions at the REST/Json level.
I model the API based on how the webpages/users want to use them rather than on DB normalization concepts. So that I minimize roundtrips.
Then the backend takes care of parsing the JSON and pumping it all into the correct tables.
This way the client does everything in a single transaction by sending all the form data in one single JSON (no matter how many entities may be affected).
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I think you are referring to the server side.
I'm referring to the client side.
If you model your API in a normalized way. How do you generally approach a situation where the UI needs to affect several entities at once? Do you have denormalized abstractions in your API?
Well, let's say we have multiple entities, each of which can be standalone entities (no foreign keys) but are referenced in some pivot tables for example. And if I had a situation where the FE sends me a request with all necessary data to create and populate multiple entities, if validation passes, we could first create entities that are not dependable, and after that, we can create all other dependencies. If for some reason it breaks, we can always roll back what we previously created. It is a bit more complex than this, but I would really like to know how do you handle N+1 problems?
What I do is I have denormalized abstractions at the REST/Json level.
I model the API based on how the webpages/users want to use them rather than on DB normalization concepts. So that I minimize roundtrips.
Then the backend takes care of parsing the JSON and pumping it all into the correct tables.
This way the client does everything in a single transaction by sending all the form data in one single JSON (no matter how many entities may be affected).