CRUD and REST
The similarities and differences between data management (CRUD) and data transfer (REST)
CRUD is an acronym that refers to the four basic operations related to data storage. Those four operations are Create, Read/Retrieve, Update, and Delete. Each word is self-explanatory:
— Create data and store it in the database
— Read or Retrieve data that’s stored in the database
— Update or change data that’s stored in the database
— Delete data that’s stored in the database
REST or RESTful is a set of guiding principles that create a stable, reliable, and predictable way to conduct data transfers over the internet. REST stands for REpresentational State Transfer. CRUD operations that conform to REST principles will map to RESTful HTTP verbs POST, GET, PUT/PATCH, and DELETE. CRUD operations map to the REST verbs in the following way:
— to Create data you have to POST it
— to Read or Retrieve data you have to GET it
— to Update data you have to PUT or PATCH it
— to Delete data you have to DELETE it
The four HTTP verbs are used to write seven different HTTP requests. GET is used to make 4 different requests and then the other three each make a single request. I’ll use songs in the following example.
— POST a newly created song in the database
— GET a list of all songs in the database
— GET a single song from the database
— GET a form to create a new song
— GET a form to edit an existing song
— PUT or PATCH existing song to change its data
— DELETE existing song from the database
Pairing the HTTP verbs with a path creates seven different requests. Whenever a specific song is targeted, it is retrieved from the database using its unique id.
Using RESTful routes simplifies CRUD operations in the development of applications. REST is a way to make data transfers over the internet and CRUD is a way to maintain data in a database. Mapping the two together in an application results in a great user experience.