CRUD—the acronym for Create, Read, Update, Delete—is a set of data-oriented functions that standardize how applications manage and exchange data across different architectural layers. CRUD operations form the basis of website development, API creation, software architecture, and database management systems. They provide a seamless framework to support persistent data management in a layered application architecture.
Key takeaways
- CRUD operations are essential operations performed for manipulating persistent data throughout the lifecycle of an application.
- CRUD operations are commonly mapped to HTTP methods in RESTful APIs, enabling standardized data exchange between different application layers.
- CRUD paradigm applies not only to databases but also to APIs and user interfaces, ensuring consistency from backend storage to frontend interaction.
- CRUD operations categorize data operations into four divisions, making database interactions structured.
Table of contents
- How do Create, Read, Update and Delete help manage and exchange data?
- Why do CRUD operations matter?
- How does CRUD relate to RESTful APIs?
- What is CRUD in programming?
- How is CRUD performed in databases?
- How do CRUD operations work?
- What does a full stack CRUD app look like?
- How are CRUD APIs secured?
- Does CRUD work differently in relational vs. NOSQL databases?
- Related resources
- FAQs
How do Create, Read, Update, and Delete help manage and exchange data?
CRUD, the acronym for Create, Read, Update, Delete, is a set of data-oriented functions that standardize how applications manage and exchange data across different layers. It organizes and divides data, mapping each to the particular business logic and database operation.
The operations are used in most of the transactional interactions that a user has with a digital platform, like a website or web application:
Creating something new (for example, a new customer profile).
Reading (like fetching order details for a user).
Updating information (like a user's mobile number or email address).
Deleting (for instance, a work phone number).
For example, when a user wants to update an address, the application logic first validates the input data by checking whether the address format is correct and whether the user has permission to perform the update.
The database layer then verifies schema rules, validates required fields, and ensures that the record exists before applying the change. Thus, each application layer has a set of responsibilities for a particular data manipulation operation.
Further, CRUD functionality can be directly mapped to HTTP methods like POST, GET, PUT, and DELETE for manipulating and managing data, providing a clean interface for end users and application developers,
Additional examples of the four operations of CRUD are:
Why do CRUD operations matter?
Whether performed individually or in bulk, CRUD operations matter because they’re fundamental to managing persistent storage in modern applications. Without CRUD operations, the application would be static and might become stale or outdated.
CRUD also provides a structured framework to perform various operations across different layers of the application, simplifying development and maintenance.
CRUD operations form the basis of designing databases, RESTful APIs, and user interfaces to enable consistent data handling across the end-to-end business application.
CRUD ensures data integrity through validations and controlled operations, and data security through access control, authentication, authorization, and logging mechanisms.
How does CRUD relate to RESTful APIs?
RESTful APIs align directly with the database CRUD principles by mapping specific HTTP request methods to each operation. RESTful APIs rely on a simple HTTP request-and-response mechanism to communicate between the client (frontend) and the server (backend).
For example, an HTTP POST request acts as a Create operation, while GET is a Read operation. The table below shows how each CRUD operation is mapped in RESTful APIs along with an example endpoint.
The front end (user interface) of an application captures the information and sends it as an HTTP request to the middleware, which calls the appropriate database functions to complete the task.
Once the task is completed, and the response is received from the database, the business layer interprets and prepares the response-HTTP status code to be sent to the front end. Here’s a simple mapping from the database response to HTTP response.
What is CRUD in programming?
CRUD serves as a foundational paradigm for manipulating data in modern web application development. Modern programming languages and frameworks support CRUD operations using query filters (NoSQL)/parameterized queries (relational); ODM/ORM abstractions; and API-driven data access mechanisms.
Below are examples of HTTP requests, the corresponding methods in a sample of programming languages, and the database methods in the context of user details.
How is CRUD performed in databases?
In relational and NoSQL databases, CRUD operations are performed with the programming language of your choice through database drivers, connectors, and query APIs.
For example, in MongoDB:
The Create operation is used to insert new documents in the database.
The Read operation is used to query a document in the database.
The Update operation is used to modify existing records in the database; if the document doesn't exist, MongoDB creates one (if the upsert option is enabled).
The Delete operation is used to remove documents from the database.
How do CRUD operations work?
The best way to see how CRUD operations work is with a real-life example. Below is an example of how CRUD operations manipulate documents in a database using MongoDB.
Create operation
For MongoDB CRUD, if the specified collection doesn't exist, the Create operation will create the collection. Create operations in MongoDB target a single collection, not multiple collections. Insert operations in MongoDB are atomic on a single document level.
MongoDB provides two different Create operations that you can use to insert documents into a collection:
insertOne()
As the name indicates, insertOne() allows you to insert one document into the collection. For this example, we're going to work with a collection called RecordsDB. We can insert a single entry into our collection by calling the insertOne() method on RecordsDB. We then provide the information we want to insert in the form of key-value pairs, establishing the schema.
The code below inserts a record with the name “Marsh”, along with age, species, and other related attributes.
If the Create operation is successful, a new document is created. The function will return an object where “acknowledged” is “true” and “insertID” is the newly created “ObjectId.”
insertMany()
It's possible to insert multiple items at one time by calling the insertMany() method on the desired collection.
Read operations
The Read operations allow you to supply special query filters and criteria that let you specify which documents you want. The MongoDB documentation contains more information on the available query filters. Query modifiers may also be used to change how many results are returned.
MongoDB has two methods of reading documents from a collection:
find()
To get all the documents from a collection, we can simply use the find() method on our chosen collection. Executing just the find() method with no arguments will return all records currently in the collection.
In the result, we can see all the records present in the collection. Note that every record has an assigned “ObjectId” mapped to the “_id” key.
findOne()
To get one document that satisfies the search criteria, we can simply use the findOne() method on our chosen collection. If multiple documents satisfy the query, this method returns the first document according to the natural order which reflects the order of documents on the disk. If no documents satisfy the search criteria, the function returns null.
Update operations
Like Create operations, Update operations operate on a single collection, and they are atomic at a single document level. An Update operation takes filters and criteria to select the documents you want to update.
You should be careful when updating documents, as Updates are permanent and can't be rolled back. This absolute applies to Delete operations as well.
For MongoDB CRUD, there are three different methods of updating documents:
updateOne()
We can update a currently existing record and change a single document with an Update operation. To do this, we use the updateOne() method on a chosen collection—-in the example below, that’s “RecordsDB.” To update a document, we provide the method with two arguments: an update filter and an update action.
The update filter defines which items we want to update, and the update action defines how to update those items. We first pass in the update filter. Then, we use the “$set” key and provide the fields we want to update as a value. This method will update the first record that matches the provided filter.
If the update is successful, we get the count of records updated.
updateMany()
updateMany() allows us to update multiple items by passing in a list of items, just as we did when inserting multiple items. This Update operation uses the same syntax for updating a single document.
replaceOne()
The replaceOne() method replaces a single document in the specified collection. replaceOne() replaces the entire document, meaning fields in the old document not contained in the new one will be lost.
Delete operations
Delete operations operate on a single collection, like Update and Create operations. Delete operations are also atomic for a single document. You can provide Delete operations with filters and criteria to specify which documents you would like to delete from a collection. The filter options rely on the same syntax that Read operations use.
MongoDB has two different methods of deleting records from a collection:
deleteOne()
deleteOne() removes a document from a specified collection on the MongoDB server. A filter criteria is used to specify the item to delete. It deletes the first record that matches the provided filter.
deleteMany()
deleteMany() is a method used to delete multiple documents from a desired collection with a single Delete operation.
MongoDB Atlas provides an efficient way to perform CRUD operations using the UI itself. Check out the MongoDB manual to learn more core MongoDB CRUD concepts to develop highly performant, scalable applications.
Get a free MongoDB Skill Badge credential on Crud Operations in just 60 to 90 minutes.
What does a full stack CRUD app look like?
In a full technology stack like a MEAN stack, MongoDB is the database, Express manages the incoming requests, Angular provides the front end and Node.js provides the runtime (server).
Consider an app that registers users to create their profile so that they can write and post blogs on various topics on the app. If a user wants to update their blog based on new information, they can do so. They can also delete it. Users can also view each other’s blogs, once posted.
Angular provides the front-end, where a user can create their profile, create a post, view their profile, view any published post, update profile, update their posts, delete profile, delete their posts. The user actions are defined by UI buttons or links like “edit profile”, “edit post”, “create post” and so on. Angular captures these and sends an HTTP request—POST, GET, PUT/PATCH or DELETE to the backend API.
Each request is validated at the server level using Node.js, and Express is the framework layer used to define the RESTful routes. This is the layer where business rules or logics are applied once the data validation, authorization, and authentication is completed. For example, a user cannot delete or create more than one post a day, a user cannot update their profile ID once it’s created, and certain users can’t unlock certain posts until 40 days after registration or after posting at least 25 blog posts. To create a post, a POST request will be sent to the database layer.
Once the backend translates the HTTP request into the corresponding MongoDB CRUD operation, the MongoDB database receives each request and processes it.
After executing the query, MongoDB sends the response back to the server, which then structures and sends it to the front end for final display.
How are CRUD APIs secured?
While CRUD route definitions and database mappings are relatively straightforward to implement, production-ready CRUD systems must incorporate centralized validation, authentication, authorization, and error-handling mechanisms to ensure secure access control and protect applications from vulnerabilities such as unauthorized access, data leaks, and malicious actions.
This can be achieved through:
Authentication: Validating a user’s identity before allowing access—through login, tokens, and session-based authentication mechanisms.
Authorization: Deciding the type of access a viewer has—admin, read only, delete, etc.
Data protection: Encrypting highly sensitive data (like passwords) and using HTTPS for secure transmission (such as a payment gateway).
CRUD-level access control: Controlling access for each operation separately—who can view what data (for example, interns can view only their project data), who can edit/insert data in particular collections (only admins can access system files and data).
Input validation: Validating all the requests for correct data types and format; rejecting malformed requests; preventing cross-site scripting and injections by data cleansing and filtering.
Does CRUD work differently in relational vs. NoSQL databases?
Yes, CRUD works differently in NoSQL vs. relational databases. NoSQL databases are better optimized for Create and Read operations and offer more scalability. Because of this, they're well suited for higher loads (handling more CRUD operations). They’re also flexible in terms of storing information.
In a detailed experiment conducted by ResearchGate on CRUD operations conducted with different types of NoSQL and SQL databases, it was concluded that NoSQL databases performed significantly better than SQL databases in all the CRUD operations, particularly when the number of operations was high. For example, MongoDB excelled in fetching data (Read operations), with a mean performance time of 43.5 ms for 100,000 Read (find/select) operations. MongoDB also has an advantage in providing atomic updates (field level updates), which is more time-consuming in any other document-oriented database.
Related resources
MongoDB CRUD operations - Explore the basics of CRUD Operations
MongoDB CRUD concepts - Learn more about advanced CRUD concepts
Translating natural language to MongoDB CRUD operations - Discover how MongoDB can translate your simple requirements in natural language (like English) to a database query


