DEV Community

Cover image for Understanding REST & CRUD Operations
Khan Anupam Shafi
Khan Anupam Shafi

Posted on

Understanding REST & CRUD Operations

What is CRUD?

CRUD stands for create, read, update, and delete in computer programming which represents the four basic operations you can do on any data. We simply create something new, can read or view the newly created data, even edit or update the data and finally the option to delete the data using CRUD operation. We can find CRUD on almost any application.

CRUD vs. REST: What’s the Difference?

CRUD and REST can sometime be confusing to new developers.
Different programming languages and protocols may use different name for CRUD operations but the idea is the same. For example SQl language calls the four functions Insert, Select, Update, and Delete
On the other hand REST is a popular architectural style for web API design used by many developers.

Image description

The confusion between CRUD and REST architecture arises from the fact that interacting with REST applications usually involves the use of CRUD-like functions. As we know in REST applications client and server interact in a uniform / predictable way.
Rest APIs communicate with clients using the HTTP protocol, which uses its own set of methods for data manipulation. These are known as http verbs : GET, POST, DELETE, PUT, and PATCH, are some known HTTP verbs . And this can overlap with CRUD functions like following:

Image description

Even though they look the same they don't map exactly to one another like PUT and POST may both correspond to CREATE in CRUD operation. But both Put and Post have their own use cases.

  • . PUT can only replace data even if that data doesn’t exist in the system. However POST usually adds a new resource. They can both be used to Create new resources, but PUT is mainly used to Update existing resources.
  • . PATCH is used to Update part of a data, whereas PUT is only used to Update a resource by replacing the whole data.

Oldest comments (1)

Collapse
 
eonuk profile image
eonuk

Nice overview. Working in testing, I often find developers don't follow correct conventions with REST.