Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is better to join data from few database tables? On Front-End or Back-End?

For example I have 3 tables and on frontend I need to show table with Users, their Positions and Departments.

I have the following tables in Database and can get it via REST API:

Users id, name, position_id (foreign key), department_id (foreign key)

Positions id, name

Department id, name

Is it better to join data to show in Users instead of position_id position name on Front-End during table generation or on Backend? What is the good practice?

I have Backend on PHP Laravel and Frontend on Vue.

Thank you very much in advance

like image 451
Dmitry Avatar asked Oct 23 '25 18:10

Dmitry


1 Answers

In the backend of course, because of two important reasons:

  1. Network bandwidth
  2. Data Security

you can write a query to fetch and combine the only needed data from those databases or provide GraphQL API in the backend.

like image 166
Madmadi Avatar answered Oct 27 '25 03:10

Madmadi