RESTful API woes

Associate
Joined
16 Mar 2005
Posts
708
Location
Staffordshire
Hi Chaps

Bear with me, I'm learning as I go...

I'm developing an Android application and I need to access a DB in the cloud. Through a bit of reading on-line, I've established that I need to implement some sort of API that sits in-front of the DB - more specifically a RESTful API, which seems to be the favourable method for allowing remote access from mobile applications.

However, I'm really struggling to get my head around the way that it works. I understand the concept of using HTTP requests to GET, POST, PUT, DELETE and utilising HTTP responses for acknowledgements. What isn't sinking in is how this fits with my SQL DB - I can't figure out how this comes to execute SQL statements.

For instance, I have a number of stored procedures in a MySQL DB, if I were to use a RESTful API and use the GET http://domain.com/api/users/'userID' - I imagine this would return a row of data from a USER table for the specified userID. But, I don't just want that user data, I want to pull other data from other tables, more specifically, I want to be using the stored procedures that are configured.

Basically, I don't understand where the SQL fits in. I don't always want to specify a userID to pull user data, I may need to search a table that contains address information and then that links to user data and returns names, email and date of birth.

I'm probably rambling on and I've probably missed the point in this!

Please put me back on track, Chaps.

Thanks

Martin
 
There's nothing restricting you to having a one-to-one relationship between tables and actions. Just create an action that collects and returns the data you need.
 
There's nothing restricting you to having a one-to-one relationship between tables and actions. Just create an action that collects and returns the data you need.

What he said. REST doesn't map one-to-one onto SQL.

A GET should pull up any kind of read, a SELECT * or SELECT * FROM WHERE foo=blah.
 
Back
Top Bottom