I am making a large scale API for a platform. And I am designing the backend API. There will be a large SQL database. Now the problem is how to design the API logic to be very flexible and maintainable long term. From what I know there are two approaches I can take
Option 1
- database layer (i.e. mysql)
- abstraction layer 1 (has an endpoint for each table in the database, and just returns the table)
- abstraction layer 2 (has an endpoint for all relevant queries a client could want such as getting all invoices "/api/orders". each endpoint queries the previous abstraction for each desired table, joins them and returns result to the client)
Option 2
- database layer (i.e. mysql) (contains views for many things)
- abstraction layer (which has en endpoint for every relevant query a user could want which is mapped to views in the database layer)
Can anyone explain the pros and cons of each method and which to generally use?
Aucun commentaire:
Enregistrer un commentaire