What Does CRUD Stand For in Databases?
CRUD is an acronym commonly used to describe how databases can work. It defines the four main operations in relational and NoSQL databases, which include Create, Read, Update, and Delete.
What is CRUD?
Relational databases are commonly used by companies to store structured data. These databases are organized into tables in which each column describes a field and each row contains an independent record. Relationships between database tables and powerful query languages make databases an invaluable tool for business.
CRUD is an acronym that outlines the four main operations in a relational database. These include:
- Create: Add a new record to the database
- Read/Retrieve: Fetch one or more records from the database
- Update: Change a record in the database
- Delete: Remove a record from the database
Let’s look at these operations in a bit more detail.
The Create operation is used when new information is being added to a database. For example, when a user creates an account with an application, it will create a new record in the database to hold the user’s username, password, and other account information.
In SQL, a Create operation likely involves the INSERT command. For example, the command INSERT INTO users (username, password) VALUES (‘john’, ‘Password!’); will create a new record in the users table containing John’s username and password.
Note, this example is for illustrative purposes only. You should never store plaintext passwords anywhere, including a database.
The Read/Retrieve operation is used to fetch existing records from a database. For example, when John attempts to log into the application, the software will need to retrieve his password from the database to compare it to the one provided when he attempted to log in.
SELECT is an SQL command used to perform a Read/Retrieve operation. For example, the command SELECT password FROM users WHERE username=’john’ should retrieve John’s password from the users table of the database.
The Update operation is used to make changes to an existing record in a database. For example, John might want to change his password from Password! to Password!123 in a misguided attempt to improve his account security.
Update operations use the UPDATE command in SQL. For example, the command UPDATE users SET password=’Password!123’ WHERE username=’john’ should update John’s password in the database.
Finally, the Delete operation is used to remove a record from a database. For example, John may wish to stop using the service and have all of his information removed from the application.
The Delete operation uses the DELETE command in SQL. For example, the command DELETE from users WHERE username=’john’ will remove John’s record from the database.
The CRUD acronym is a useful tool for remembering what databases can and can’t do with a user record. Since a database offers mutable storage, an application can create records, read/retrieve them, make updates as needed, or delete the information when it is no longer needed.