CRUD — Explained with Examples
CRUD is an acronym for Create, Read, Update, Delete — the four basic operations for persistent storage in databases and APIs.
CRUD stands for Create, Read, Update, Delete, the four essential functions of persistent storage. Every database, REST API, and data-driven application implements these operations in some form.
Why CRUD Matters
CRUD is the foundation of data interaction. Whether you’re building a social network, a banking system, or a to-do app, every feature ultimately maps to creating, reading, updating, or deleting data. Understanding CRUD helps you design APIs, databases, and user interfaces consistently.
Real-World Analogy
A library: Create is adding a new book to the catalog. Read is looking up a book’s location. Update is changing a book’s shelf number. Delete is removing a deaccessioned book from the system. These four actions cover 99% of library operations.
Example: CRUD in SQL and REST
-- SQL CRUD
CREATE TABLE users (id INT, name TEXT);
INSERT INTO users (id, name) VALUES (1, 'Alice'); -- Create
SELECT * FROM users WHERE id = 1; -- Read
UPDATE users SET name = 'Alice B.' WHERE id = 1; -- Update
DELETE FROM users WHERE id = 1; -- Delete# REST API CRUD — Flask example
from flask import Flask, jsonify, request
app = Flask(__name__)
users = {}
@app.route('/users', methods=['POST']) # Create
def create_user():
data = request.json
users[data['id']] = data
return jsonify(data), 201
@app.route('/users/<int:id>', methods=['GET']) # Read
def get_user(id):
return jsonify(users.get(id, {}))
@app.route('/users/<int:id>', methods=['PUT']) # Update
def update_user(id):
users[id] = request.json
return jsonify(users[id])
@app.route('/users/<int:id>', methods=['DELETE']) # Delete
def delete_user(id):
users.pop(id, None)
return '', 204Related Terms
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro