Skip to content
What is CRUD — Simple Explanation with Examples

What is CRUD — Simple Explanation with Examples

DodaTech Updated Jun 20, 2026 5 min read

CRUD (Create, Read, Update, Delete) is the four basic operations for persistent data storage, mapping directly to SQL statements and HTTP methods in RESTful APIs.

In this guide, you’ll learn what each CRUD operation does, how they map to databases and APIs, and how to implement them in Python and SQL. CRUD is the foundation of virtually every data-driven application.

Why CRUD Exists — The Problem It Solves

Every application that stores data needs four fundamental capabilities:

  1. Create — add new data (register a user, create a post)
  2. Read — retrieve existing data (view profile, list products)
  3. Update — modify existing data (change email, edit a comment)
  4. Delete — remove data (cancel account, delete a file)

These four operations cover 95% of data interactions in any application. CRUD provides a universal mental model that works across databases, APIs, and user interfaces.

Why “CRUD” Instead of Something Else?

The term was popularized in the 1980s (possibly earlier) as a way to describe the essential operations of persistent storage. Every data system — from SQL databases to NoSQL stores to file systems — implements these four operations in some form.

The Analogy — Library Book Management

Think of a library’s book management system:

CRUDLibrary OperationExample
CreateAdd a new book to the catalogRegister a new ISBN entry
ReadLook up a book by title or authorSearch the catalog
UpdateChange a book’s location or statusMark as “checked out”
DeleteRemove a withdrawn book from catalogDelete damaged books

The library clerk (your application) needs all four operations to manage the collection. Without any one of them, the system is incomplete.

CRUD → SQL Mapping

OperationSQL CommandDescription
CreateINSERTAdd a new row to a table
ReadSELECTRetrieve rows from a table
UpdateUPDATEModify existing rows
DeleteDELETERemove rows from a table

SQL Examples

-- CREATE: Add a new user
INSERT INTO users (name, email, age)
VALUES ('Alice', 'alice@example.com', 30);

-- READ: Retrieve users
SELECT * FROM users WHERE age > 25;

-- UPDATE: Change Alice's email
UPDATE users
SET email = 'alice@newdomain.com'
WHERE name = 'Alice';

-- DELETE: Remove users under 18
DELETE FROM users WHERE age < 18;

CRUD → HTTP Method Mapping

OperationHTTP MethodREST URIStatus Code
CreatePOST/users201 Created
ReadGET/users/{id}200 OK
UpdatePUT or PATCH/users/{id}200 OK
DeleteDELETE/users/{id}204 No Content

REST API Examples

# CREATE
POST /api/users
Content-Type: application/json

{"name": "Bob", "email": "bob@example.com"}
→ 201 Created
→ Location: /api/users/42

# READ
GET /api/users/42
→ 200 OK
→ {"id": 42, "name": "Bob", "email": "bob@example.com"}

# UPDATE (full replacement)
PUT /api/users/42
Content-Type: application/json

{"name": "Robert", "email": "robert@example.com"}
→ 200 OK

# UPDATE (partial)
PATCH /api/users/42
Content-Type: application/json

{"email": "newemail@example.com"}
→ 200 OK

# DELETE
DELETE /api/users/42
→ 204 No Content

CRUD Example in Python with SQLite

import sqlite3

conn = sqlite3.connect('library.db')
cursor = conn.cursor()

# Create table
cursor.execute('''
    CREATE TABLE IF NOT EXISTS books (
        id INTEGER PRIMARY KEY AUTOINCREMENT,
        title TEXT NOT NULL,
        author TEXT NOT NULL,
        year INTEGER
    )
''')

# --- CREATE ---
cursor.execute(
    'INSERT INTO books (title, author, year) VALUES (?, ?, ?)',
    ('1984', 'George Orwell', 1949)
)
print(f"Created book with id: {cursor.lastrowid}")

# --- READ ---
cursor.execute('SELECT * FROM books WHERE author = ?', ('George Orwell',))
books = cursor.fetchall()
for book in books:
    print(f"Read: {book}")

# --- UPDATE ---
cursor.execute(
    'UPDATE books SET year = ? WHERE title = ?',
    (1950, '1984')
)
print(f"Updated {cursor.rowcount} row(s)")

# --- DELETE ---
cursor.execute('DELETE FROM books WHERE year < ?', (1900,))
print(f"Deleted {cursor.rowcount} row(s)")

conn.commit()
conn.close()

Expected output:

Created book with id: 1
Read: (1, '1984', 'George Orwell', 1949)
Updated 1 row(s)
Deleted 0 row(s)

REST API CRUD with Flask

from flask import Flask, request, jsonify

app = Flask(__name__)

books = [
    {"id": 1, "title": "1984", "author": "George Orwell"},
    {"id": 2, "title": "Brave New World", "author": "Aldous Huxley"},
]
next_id = 3

# CREATE
@app.route('/api/books', methods=['POST'])
def create_book():
    global next_id
    data = request.get_json()
    book = {"id": next_id, "title": data['title'], "author": data['author']}
    books.append(book)
    next_id += 1
    return jsonify(book), 201

# READ (all)
@app.route('/api/books', methods=['GET'])
def get_books():
    return jsonify(books)

# READ (one)
@app.route('/api/books/<int:book_id>', methods=['GET'])
def get_book(book_id):
    book = next((b for b in books if b['id'] == book_id), None)
    if book is None:
        return jsonify({"error": "Not found"}), 404
    return jsonify(book)

# UPDATE
@app.route('/api/books/<int:book_id>', methods=['PUT'])
def update_book(book_id):
    book = next((b for b in books if b['id'] == book_id), None)
    if book is None:
        return jsonify({"error": "Not found"}), 404
    data = request.get_json()
    book.update(data)
    return jsonify(book)

# DELETE
@app.route('/api/books/<int:book_id>', methods=['DELETE'])
def delete_book(book_id):
    global books
    book = next((b for b in books if b['id'] == book_id), None)
    if book is None:
        return jsonify({"error": "Not found"}), 404
    books = [b for b in books if b['id'] != book_id]
    return '', 204

if __name__ == '__main__':
    app.run(debug=True)

Common Use Cases

1. User management systems

Register (Create), log in (Read), edit profile (Update), delete account (Delete) — the classic CRUD pattern.

2. Content management systems

Create articles, read published posts, update drafts, delete outdated content. WordPress and other CMS platforms are essentially CRUD interfaces.

3. E-commerce catalogs

Add products (Create), browse listings (Read), update prices (Update), remove discontinued items (Delete).

4. Task management apps

Create tasks, view today’s tasks, mark as complete (Update), delete completed tasks. Every to-do app is CRUD.

5. Database admin tools

phpMyAdmin, Adminer, and DBeaver are graphical CRUD interfaces that let users perform SQL operations without writing SQL.

FAQ

What is the difference between PUT and PATCH?

PUT replaces the entire resource. PATCH applies partial modifications. Use PUT when the client sends the full resource; use PATCH for partial updates.

Is CRUD always mapped to a database?

No. CRUD is a pattern. It applies to files (create/read/update/delete), in-memory data structures, and even hardware (sensor registers).

What about “B” in CRUD?

Some add “B” for Browse (listing/searching), making it BREAD: Browse, Read, Edit, Add, Delete. But CRUD is the widely accepted standard.

Can I have an API without CRUD?

Yes. Some APIs are purely analytical (read-only) or use event-driven patterns (queue-based processing). But most data APIs follow CRUD.

What is a “CRUD application”?

An application whose primary functionality is creating, reading, updating, and deleting records — typically with a database and a UI. Most business apps are CRUD apps.

Related Terms

REST API, SQL, ORM, API, Database

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro