DEV Community

ERICK MIRANDA G
ERICK MIRANDA G

Posted on

Where should I handle inserting data into multiple related tables: frontend or backend?

My current structure is:

Table

  • Order
  • Product

In the UI, the user creates a new order and dynamically adds multiple products to it within the same interface. When the user finishes, there is only one submit button that sends all the information.

For example, should the frontend send multiple requests (one for the order and others for products), or should it send one request containing everything and let the backend manage database operations?

Additionally, the products are not reused. Each product is unique and is created at the moment the user submits the order. In other words, products do not exist beforehand in a catalog; they are generated dynamically as part of the order creation process.

Top comments (0)