GeeGoldz
GeeGoldz

Reputation: 187

Is a restful service needed to access/update a database?

I have a MySql database set up and a mobile app that should be able to write/read to and from the database.

The data being stored will be posts, comments, votes, etc.

Eventually, I might create a website that uses the same database.

My question is, do I need some sort of middleman (restful) service running or can I just connect straight to the MySql db from the client code (either the mobile app or website)?

Upvotes: 2

Views: 65

Answers (2)

Supun Wijerathne
Supun Wijerathne

Reputation: 12958

Introducing a REST api into the middle would be much beneficial in a lot of ways.

  • Improve generalization and reuse. (REST api can be used by both mobile client and web client, no need to do the same work twice)
  • Can maintain business logic centrally. (If there's a logic to change or a bug fix, no need to correct in 2 places)
  • Can be easily exposed to any other app/client which would need the set of operations provided by the api.
  • Extending and maintenance of the app would be much simplified and would take minimum effort.

Upvotes: 2

Glenner003
Glenner003

Reputation: 1587

Especially with the mobile application, where you have much less control of updates, it seems better to use some middle-ware to connect to your database.

Say for instance your website needs a little change in the database that would break an active version of the mobile application. A web service could catch that for you. What about a new version of your mobile app that needs a change. Again a web service can handle that for you.

This is all about cutting dependencies and keep the complete ecosystem adaptable.

Whether this is a rest or any other type of web service is a completely different discussion.

Upvotes: 1

Related Questions