Jack Damon February 2016

Relationship between REST API & Database

I've been studying databases and rest APIs lately and I have a question about the relationship between the two.

Imagine I have a database with three tables, STUDENTS, ENROLLED, and CLASSES.

STUDENTS and CLASSES denote the entities students and classes, whereas the ENROLLED table denotes their relationship.

If I were to map this dataset in a rest api, would I just have 3 different CRUD routes with the three tables, eg ('/students', '/classes', '/enrolled')?

And that question goes for REST APIs in general -- when you write/make a REST API, are you just constructing a 1:1 mapping of your database?

Thanks so much in advance-- just trying to really nail down my conceptual understanding of the relationship between the two.

Cheers!

Answers


Mahbub Morshed Prottoy February 2016

HTTP verbs are mostly used for CRUD operations but while writing/ making a REST API you are not necessarily constructing a 1:1 mapping of your database.

Rest can have hypermedia controls. Like if somebody wants to to get a doctors appointment he first needs to get the available appointment slot and than using that appointment slot he can make a request to make an appointment. While delivering the available appointment slot you can send the url for booking that slot.

Read this - http://martinfowler.com/articles/richardsonMaturityModel.html

Post Status

Asked in February 2016
Viewed 2,696 times
Voted 6
Answered 1 times

Search




Leave an answer