Contents
Which is better REST API or directly DB calls?
When it comes to a large applications with huge database containing milions of records, you soon realize, plain selects, updates, inserts and deletes simply are not enough. So you start thinking in a different way. You create procedures and triggers to take care of more complicated stuff directly in the database and this is not very good.
Why is a data API better than a database?
In fact, even if you manage to build your own database, scattering SQL statements all over your application will only cause future headaches as your DB undergoes the inevitable schema changes. Worse case, even IF you manage to create your own database, maintaining that data freshness is going to take up much of your time.
How to create a data access layer ( C # )?
When working with data one option is to embed the data-specific logic directly into the presentation layer (in a web application, the ASP.NET pages make up the presentation layer). This may take the form of writing ADO.NET code in the ASP.NET page’s code portion or using the SqlDataSource control from the markup portion.
How to define REST API in desktop application?
Depending on your platform you may find tooling that almost makes the problem go away – Microsoft have ODATA support for connected apps that should makes forms over data straightforward once you’ve climbed the learning curve. More pragmatically – define the API you need for your data layer in the desktop application and code to that API.
What are the benefits of REST API layer?
In your architecture (if I understand it correct), you have browsers interacting with a single web app, which in turn is interacting with the database. Introducing a REST API layer between the web app and the database has no benefit. All the stated benefits (caching, isolation of database etc) can be achieved with data access layer (s) in code.
Is it good to have REST API in web app?
You are right, there is no clear benefit to introduce a REST API layer between a web app and a database, and it has a cost in complexity and performance overhead. The reason you are getting contradictory answers is confusion about what is the ‘client’ in your architecture.
Why is isolating a database behind an API better?
That is, I am not touching at all on the REST part – isolating your database behind an API is simply a more sensible choice if the team that maintains the database and the teams that use it are not in sync, as it allows these parts to evolve at their own pace.
Why is the API of multiple microservices not well designed?
The API of multiple microservices might not be well designed for the needs of different client applications. For instance, the needs of a mobile app might be different than the needs of a web app. For mobile apps, you might need to optimize even further so that data responses can be more efficient.
Is the direct client to microservice architecture good?
A direct client-to-microservice communication architecture could be good enough for a small microservice-based application, especially if the client app is a server-side web application like an ASP.NET MVC app.
When do you call directly to the database?
The Business Logic is also needed when calling directly the database. It won’t take much longer to develop When it comes to a large applications with huge database containing milions of records, you soon realize, plain selects, updates, inserts and deletes simply are not enough. So you start thinking in a different way.
Is the REST API a database or a document store?
A REST API is not a database access protocol, so the question is a big of a category error. A REST api is a document store. It MIGHT use a database on the server side (or it might not).
Is it good idea to have direct access to database?
Ideally, you should always have a mediator between the database and the client implementing its own business rules. Providing direct access to database is not a good idea, because when you do so, the one with access has direct access to the tables and can do pretty much anything with the data there is.