What are the pros and the cons when we have the choice between using direct database access or using web services?
What would be your choice for a critical application that should be responsive (<0.5 sec) and with a low call to this webservice/DB (NB: the web service will be maintained by another team).
But with the web service between the user and the database, the connection to the database is more secure since the user cannot directly access it. (Except for the functionality you provide through the web service.)
A web service can act as the single steward of the data. You'll get away with going directly against the database when it's just your app, but if other apps come along and require the same data you'll increase the chances that they'll need schema changes some day. Those changes will affect your app as well.
Obviously, a direct database access will always be faster in simple scenarios. With a WebService, you gain flexibility :
Giving users direct access to the db poses risks. Both approaches open the door to exploiting desktop dll's to connect to db outside of application context (Multiple times I've seen cases where there is a common data access class that all functional operations use. And of course, this components initializes all the connection information.
Direct database access couples you tightly to the schema. Any changes on either end affects the other. But it's got the virtues of being simple and requiring one less network hop.
A web service means better abstraction and looser coupling via one additional level of indirection. A web service can act as the single steward of the data. You'll get away with going directly against the database when it's just your app, but if other apps come along and require the same data you'll increase the chances that they'll need schema changes some day. Those changes will affect your app as well. The cost is more latency.
A web service can be a good place to centralize authorization and security. A database can do this as well, so perhaps it's a wash.
Obviously, a direct database access will always be faster in simple scenarios.
With a WebService, you gain flexibility :
Given your context of responsiveness (with possibly a problem with the other team), I would try to go the direct database access route, unless several applications need to share the data...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With