In the world of database management systems (DBMSs) and computer programming, CRUD is an acronym that stands for Create, Read, Update, and Delete. These are considered to be the four basic operations of persistent storage.
Let’s take a look at how CRUD fits into database management systems and programming in general.
What Does CRUD Stand For?
CRUD is an acronym that stands for Create, Read, Update, and Delete.
There are some variations around this, such as Create, Retrieve, Update, and Delete.
There’s also a variation that’s used in computer networking in which the R stands for Replace (i.e. Create, Replace, Update, and Delete).
What Does CRUD Do?
In the context of database systems and computer programming, CRUD is a set of basic operations that can be performed on data in a database or other data storage system. CRUD operations are typically used in software applications that interact with databases to manage data.
Here’s a brief description of each operation:
- Create: The process of adding new data to the database. For example, creating a new row in a database table, or adding a new document to a document storage system.
- Read: The process of retrieving existing data from the database. For example, reading a row from a database table, or retrieving a document from a document storage system.
- Update: The process of modifying existing data in the database. For example, updating the value of a column in a database table, or editing the content of a document in a document storage system.
- Delete: The process of removing data from the database. For example, deleting a row from a database table, or removing a document from a document storage system.
CRUD operations are a fundamental part of many software applications, and are often implemented using programming languages and frameworks that provide APIs or libraries for interacting with databases. For example, many web applications use frameworks such as Ruby on Rails or Django to perform CRUD operations on a backend database, while front-end frameworks like React or Angular can provide interfaces for users to interact with the data.
CRUD in SQL
When it comes to SQL, many operations can be performed using a CREATE
, UPDATE
, or DELETE
statement. However, these don’t always correspond with the CRUD operation of the same name.
The following table shows how SQL provides for the various CRUD operations:
So even though SQL has various CREATE
statements (such as the CREATE TABLE
statement), they don’t add data. The INSERT
statement adds data. There are also other approaches, such as BULK INSERT
, but these will depend on the DBMS being used.
On the other hand, the UPDATE
statement does update data, and the DELETE
statement does delete data.
For the “Read” part of CRUD, SQL provides us with the SELECT
statement.
CRUD in NoSQL
CRUD isn’t just limited to relational databases. It also applies to NoSQL databases. When used in NoSQL databases, the actual commands used will depend on the database product.
For example the following table shows how certain MongoDB commands map to the CRUD operations:
CRUD | Commands |
---|---|
Create | db.collection.insertOne() db.collection.insertMany() |
Read | db.collection.find() db.collection.findOne() |
Update | db.collection.updateOne() db.collection.updateMany() db.collection.replaceOne() |
Delete | db.collection.deleteOne() db.collection.deleteMany() db.collection.remove() |
MongoDB also has many other commands that include CRUD operations in their functionality, such as db.collection.bulkWrite()
, db.collection.findOneAndReplace()
, db.collection.findOneAndUpdate()
, and db.collection.findAndModify()
, to name a few.
CRUD operations can also be performed in the aggregation pipeline with stages such as $addFields
, $set
, $project
, $unset
, $replaceRoot
, and $replaceWith
.
CRUD in REST APIs
The CRUD concept can also be applied to REST APIs. We can map HTTP methods to each CRUD letter as follows:
CRUD | HTTP |
---|---|
Create | POST |
Read | GET |
Update | PUT |
Delete | DELETE |
User Interfaces
CRUD is a concept that can be applied at the user interface level. When using an application, a user often needs to be able to initiate each of the CRUD operations. A user may need to create, read, update, and/or delete stuff. The exact operations that a user can perform will depend on the user and the application.
For example, when using a content management system to provide content for a website, a content provider may need to be able to create articles, read articles, update articles, and delete articles. On the other hand, a website visitor may only need to read the article.
Other CRUD-like Variations
Although CRUD is a widely used acronym, other similar acronyms and initialisms occasionally arise. Below are some acronyms/initialisms that have been proposed over the years:
ABCD
: Add, browse, change, delete.CRUD
: In addition to the definition outlined above for databases and computer programming, the CRUD acronym is sometimes used in computer networking in which the R stands for Replace (i.e. Create, Replace, Update, and Delete).CRUDL
: Create, read, update, delete, list. Example: AWS Cloud Control API.ISUD
: Initialism for theINSERT
,SELECT
,UPDATE
, andDELETE
statements in SQL.BREAD
: Browse, read, edit, add, delete.DAVE
: Delete, add, view, edit.CRAP
: Create, replicate, append, process. Example: Dell Technologies Blog. CRAP has also jokingly been proposed as a synonym for CRUD by making it an acronym for Create, Retrieve, Alter, Purge.