Skip to content
BENIBIX Learn

Create, Read, Update, Delete (CRUD)

Development🗃️ DatabasesDatabase Basics

Also known as CRUD, CRUD Operations, CRUD App

The four jobs you do on data: add it, read it, change it, and delete it.

Think of it like

It is like a box of cards. You add a card, read it, fix it, or throw it away.

Example

Jack builds a to-do app. Adding a task, listing tasks, ticking one off and removing one are its four CRUD jobs.

Why it matters

Most apps are CRUD at heart. Once you can do these four jobs, you can build the core of a lot of software.

Definition

CRUD stands for the four basic jobs you do with stored data: create, read, update and delete. Almost every app does these to its records. A notes app makes a note, shows it, changes it and removes it. In SQL the four jobs are INSERT, SELECT, UPDATE and DELETE. In a web API they are often POST, GET, PUT and DELETE.

Example code

sql
INSERT INTO tasks (title) VALUES ('Buy milk');
SELECT * FROM tasks;
UPDATE tasks SET done = true WHERE id = 1;
DELETE FROM tasks WHERE id = 1;
Create, read, update and delete, one SQL line each.
The four jobs, and the words SQL and a web API use for each.

Common mistake

Running UPDATE or DELETE with no WHERE. It changes or wipes every row in the table, not just the one you meant.

Key takeaways

  1. 1
    Four jobs. Create, read, update, delete.
  2. 2
    Same in many places. SQL, web APIs and app screens.
  3. 3
    Aim before you change. UPDATE and DELETE need a WHERE.