Backend Fundamentals

CRUD Operations, Explained Properly

Every app you have ever used — from Instagram to your banking app — is quietly running the same four moves on data behind the scenes. Here's exactly what they are, how they map to SQL and REST, and how to build them yourself.


| By Affordable AI, Nagpur



CRUD Operations Explained: Create, Read, Update, Delete — The Complete Guide
01 · The basics

What does CRUD actually mean?

CRUD stands for Create, Read, Update, and Delete — the four basic operations you can perform on any piece of stored data. Whether that data lives in a SQL database, a NoSQL document store, or a simple JSON file, almost every feature you build eventually reduces to one of these four actions.

Client app / browser CREATE READ UPDATE DELETE Database requests →

Think of a spreadsheet. Adding a new row is Create. Opening it to view the data is Read. Editing a cell is Update. Removing the row entirely is Delete. Every backend system, no matter how complex, is built on top of these same four moves — just wrapped in more structure, validation, and security.

02 · The four operations

Each operation, broken down

Here's what each letter of CRUD means in practice — with the matching HTTP method, SQL statement, and a working code example.

Create — adding new data

POST

Create is how new records come into existence — a new user signing up, a new product added to a store, a new comment posted under a photo. In SQL this is an INSERT statement; in a REST API it's almost always a POST request.

SQL
INSERT INTO users (name, email)
VALUES ('Riya Sharma', 'riya@mail.com');
Node.js · Express
app.post('/users', async (req, res) => {
  const user = await User.create(req.body);
  res.status(201).json(user);
});

Real-world analogy: filling out a fresh index card and dropping it into the drawer for the first time.

Read — viewing existing data

GET

Read is how you fetch data that already exists — your Instagram feed loading, a product page opening, search results appearing. It never changes anything; it only retrieves. SQL uses SELECT, REST APIs use GET.

SQL
SELECT id, name, email
FROM users
WHERE id = 1042;
Node.js · Express
app.get('/users/:id', async (req, res) => {
  const user = await User.findById(req.params.id);
  res.json(user);
});

Real-world analogy: pulling a card out of the drawer just to read it — you put it right back, unchanged.

Update — modifying existing data

PUT / PATCH

Update changes data that already exists — editing your bio, changing an order's shipping address, marking a task as complete. SQL uses UPDATE; REST APIs use PUT (replace the whole record) or PATCH (change just a few fields).

SQL
UPDATE users
SET email = 'riya.new@mail.com'
WHERE id = 1042;
Node.js · Express
app.patch('/users/:id', async (req, res) => {
  const user = await User.findByIdAndUpdate(
    req.params.id, req.body, { new: true }
  );
  res.json(user);
});

Real-world analogy: pulling out the card, crossing out the old phone number, and writing the new one — same card, updated details.

Delete — removing data

DELETE

Delete permanently removes a record — deleting a post, cancelling an account, clearing an old notification. SQL uses DELETE; REST APIs use the DELETE method. This is the only operation that should always ask for confirmation first.

SQL
DELETE FROM users
WHERE id = 1042;
Node.js · Express
app.delete('/users/:id', async (req, res) => {
  await User.findByIdAndDelete(req.params.id);
  res.status(204).send();
});

Real-world analogy: pulling the card out of the drawer for good and shredding it.

Create = insert new Read = fetch existing Update = modify existing Delete = remove permanently
03 · Cheat sheet

CRUD → SQL → REST → HTTP, side by side

This is the table every backend developer eventually memorises. Bookmark it.

CRUDSQL StatementHTTP MethodTypical EndpointSuccess Code
CreateINSERTPOST/users201 Created
ReadSELECTGET/users/:id200 OK
UpdateUPDATEPUT / PATCH/users/:id200 OK
DeleteDELETEDELETE/users/:id204 No Content
04 · SQL vs NoSQL

Does CRUD work the same way in every database?

The four operations stay identical in concept — only the syntax changes depending on the database you're using.

OperationSQL (MySQL / PostgreSQL)NoSQL (MongoDB)
CreateINSERT INTO table VALUES (...)db.collection.insertOne({...})
ReadSELECT * FROM table WHERE id=1db.collection.findOne({id:1})
UpdateUPDATE table SET x=y WHERE id=1db.collection.updateOne({id:1},{$set:{x:y}})
DeleteDELETE FROM table WHERE id=1db.collection.deleteOne({id:1})
05 · Hands-on

Build a mini Notes API in four steps

Here's the exact order you'd follow to wire up CRUD for a simple "Notes" feature using Express and MongoDB.

01

Create the model

Define a Note schema with title and content fields.

02

Add a POST route

Accept new note data from the client and save it to the database.

03

Add GET / PATCH routes

Let the client fetch all notes, fetch one note, and edit an existing note.

04

Add a DELETE route

Remove a note permanently once the user confirms they want it gone.

06 · Best practices

Writing CRUD APIs that don't break in production

Validate before you Create

Never trust incoming data. Check required fields, types, and formats before writing anything to the database.

Paginate your Reads

Never return an entire table at once. Use limit and offset (or cursors) so large datasets don't crash the client.

Use PATCH for partial Updates

Reserve PUT for full replacements, and PATCH when the client is only changing one or two fields.

Soft-delete when it matters

For anything valuable, flag a record as deleted: true instead of removing it, so it can be recovered later.

Return the right status codes

201 for Create, 200 for Read/Update, 204 for Delete — clients rely on these to know what happened.

Authorize every operation

Check that the requesting user actually owns or is allowed to touch the record before Update or Delete runs.

07 · Pitfalls

Mistakes beginners make with CRUD

1

Using GET to change data

GET requests should never create, update, or delete anything — browsers and crawlers can trigger them without the user meaning to.

2

Skipping input validation

An unchecked Create or Update request is the easiest way to fill your database with broken or malicious data.

3

Hard-deleting everything

Permanently deleting records with no backup means one bad request can wipe out data you can never get back.

4

No error handling

A failed database call with no try/catch will crash your server instead of returning a clean error to the client.

08 · FAQ

Frequently asked questions

Is CRUD only for databases?

No. CRUD is a general pattern for managing any stored data — it applies to databases, but also to files, in-memory caches, and even browser local storage.

What's the difference between PUT and PATCH?

PUT replaces the entire resource with the data you send. PATCH updates only the specific fields included in the request, leaving the rest untouched.

Do all four operations always need their own route?

Usually yes, in a REST API — each operation maps to its own HTTP method and endpoint. GraphQL APIs handle this differently, using queries for Read and mutations for Create, Update, and Delete.

Why is Delete considered the riskiest operation?

Because it's irreversible by default. That's why production systems often use soft deletes, confirmation prompts, and strict authorization checks before allowing it.