DEV Community

Cover image for CRUD operation
Sachini Darshika
Sachini Darshika

Posted on

CRUD operation

What is CRUD??
CRUD, which stands for Create, Read, Update, and Delete, represents the four basic operations that can be performed on data. These operations are fundamental in database management and are commonly associated with persistent storage.

Create (C)
Read (R)
Update (U)
Delete (D)

In the context of web development and databases, CRUD operations are often associated with HTTP methods:

Create: Usually mapped to the HTTP POST method.
Read: Usually mapped to the HTTP GET method.
Update: Usually mapped to the HTTP PUT or PATCH method.
Delete: Usually mapped to the HTTP DELETE method.

Create (C)---->POST (Send Data)

Image description

  • 'POST' sends data to the server for processing or to create a new resource.
  • Suited for submitting form data or uploading a file.
  • Initiates actions that may result in a change of server state.

Image description

Read (R)---->GET(Retrieve Information)

Image description

  • Use 'GET' to fetch data from a specified resource.
  • Ideal for retrieving information without modifying the server's state.
  • Commonly employed for reading or viewing data from a database or API.

Image description

Update(U)---->PUT(Update Information)

Image description

  • Employ 'PUT' to update or create a resource at a specific URL.
  • Useful for modifying existing data or creating a new resource if it doesn't exist.
  • Ensures the resource at the specified URL reflects the provided data.

Image description

Delete (D)---->DELETE(Remove Data)

Image description

  • 'DELETE' removes a specified resource or data from the server.
  • Integral for discarding unnecessary information or undoing prior actions.
  • Use with caution, as it permanently deletes the server

Image description

CRUD operations are essential for interacting with databases and are commonly associated with corresponding HTTP methods in web development. These operations provide a standardized way of managing data, ensuring consistency and integrity in applications that involve persistent storage.

Top comments (0)