dark mode light mode Search Menu


W_Minshuli on Flickr

CRUD is not a league of super heroes or super villains. Instead, CRUD is an acronym for the four basic database-related functions programmers encounter as they create software.

Each letter in CRUD refers to tasks performed with databases:

  • Create or add data
  • Retrieve data
  • Update data
  • Delete data

This acronym likely was created in the 1980s to describe database functionality used by SQL (structured query language) databases. Each letter maps to an SQL operation: INSERT (create), SELECT (retrieve), UPDATE (update), and DELETE (delete). However, these operations also apply to non-SQL databases, for example, MongoDB and BigTable.

How CRUD Works

In practical terms, you likely would have functions or methods to create a data record in the database, retrieve the data record, update a specific data record (usually with the unique ID of the record), and delete a data record (also using the unique ID of the record).

For example, almost all online software applications include the ability for people to sign up to use the application. Here’s how CRUD works with user accounts:

  • When a person signs up, the application creates a database record with their user profile which includes their login information.
  • When they login, another function or method takes their login credentials and retrieves data from the database to confirm they have permission to use the application.
  • If they change their password, the application updates their data record so their next login attempt will validate their credentials correctly.
  • If the person wants to delete their account, a function or method uses their account ID to delete their account data from the application.

CRUD works for every part of any software application which uses a database. For example, an online application to publish content will have user accounts plus the ability to create, retrieve, update, and delete content. It also might have the ability to create, retrieve, update, and delete categories, comments, and other data useful in publishing content.

Often programmers must provide users with forms to allow them to create, retrieve, update, and delete data. This data is then used by the internal functions or methods to interact with the database.

If you write enough software applications, eventually you develop a set of code you can copy and paste to provide user forms and code to interact with the database. Most of your work then becomes a matter of checking the forms are correct for the new application and data is captured then entered or modified in the database correctly. Code to retrieve and delete data also needs to be tweaked to reflect new database table names and similar details. Programmers hired to maintain a software applications know to look for these specific functions or methods in the code base.

To make things even more interesting, code frameworks like Ruby on Rails provide an easy way to access CRUD operations with any database. Instead of coding to interact directly with the database, you pass the data to Ruby on Rails or other framework to handle database interactions. This is a much safer and cleaner way to write software programs that interact with databases.

Beyond CRUD

Some purists would add an S to CRUD for Search. While create, update, and delete affect database data directly, retrieving data does not. Also, retrieving data is used only for updates and deletions. Search also could be limited to database updates and deletions. However, users of software applications often need to search data in the database and see a list of possible search results. The counter argument is that search is a part of retrieving data, not a separate activity.

While CRUD is a common term with programmers, there are other variations beyond SCRUD. For example, some add an L to the acronym for listing large blocks of data, an activity which requires pagination to manage a block of data to display subsets of the data on multiple pages. Pagination requires tracking which subset of unique data to display to the user from the larger block of data.

As a practical matter, programmers who design a new program know they will need functions or methods to create, retrieve, update, and delete data. And programmers who maintain an application know where to go in the code if there’s a bug with the core database functionality. CRUD is both practical and abstract.

While CRUD is not the name of a league of superheroes, it is a powerful concept used everywhere in software that uses a database.

Learn More



CRUD, Only When You Can Afford It

A technical article describing the limitations of thinking in terms of Create, Retrieve, Update, Delete in programming.

Difference Between REST and CRUD

If you have patience, an excellent discussion that highlights how CRUD works in software programming relative to another aspect of programming, REST.

CRUD: Another Acronym Bites the Dust

John Gavin points out another meaning of CRUD, from the nuclear industry, turns out to be untrue.