Create, Read, Update, and Delete operations (CRUD operations)

📌 What are CRUD Operations?

CRUD stands for Create, Read, Update, and Delete — the four basic operations for interacting with data in a database system. These are fundamental actions for managing persistent data and are crucial for any Business Analyst (BA) to understand when working with databases or IT systems.


🔑 Overview of CRUD Operations

Operation

Action

SQL Command Used

Create

Add new data/record to a database

INSERT

Read

Retrieve or view data from a database

SELECT

Update

Modify or edit existing data

UPDATE

Delete

Remove existing data/record

DELETE


Detailed Explanation of Each Operation


1. CREATE - Adding New Records

  • Purpose: To insert new rows of data into a table.

Syntax:

sqlCopyEditINSERT INTO table_name (column1, column2, ...) 
VALUES (value1, value2, ...);

Example:

sqlCopyEditINSERT INTO employees (name, age, position, salary) 
VALUES ('Alice Johnson', 30, 'Data Analyst', 50000);

2. READ - Retrieving Data

  • Purpose: To fetch data from a table for viewing or processing.

Syntax:

sqlCopyEditSELECT column1, column2, ... FROM table_name WHERE condition;

Example:

sqlCopyEditSELECT name, position FROM employees WHERE age > 25;
  • To get all data:

sqlCopyEditSELECT * FROM employees;

3. UPDATE - Modifying Existing Records

  • Purpose: To update existing data in a table.

Syntax:

sqlCopyEditUPDATE table_name 
SET column1 = value1, column2 = value2, ...
WHERE condition;

Example:

sqlCopyEditUPDATE employees 
SET salary = 55000 
WHERE name = 'Alice Johnson';

⚠️ Important: Always use a WHERE clause to avoid updating all records unintentionally.


4. DELETE - Removing Records

  • Purpose: To delete data from a table.

Syntax:

sqlCopyEditDELETE FROM table_name WHERE condition;

Example:

sqlCopyEditDELETE FROM employees WHERE name = 'Alice Johnson';

⚠️ Caution: Omitting WHERE clause will delete all rows in the table.


🧭 CRUD Operations Example on a Table

Sample Table: employees

id
name
age
position
salary

1

John Doe

28

Developer

60000

2

Jane Smith

32

Manager

75000

3

Alice Johnson

30

Data Analyst

50000


Operation

SQL Command Example

Create

INSERT INTO employees (name, age, position, salary) VALUES ('Bob Martin', 29, 'Tester', 45000);

Read

SELECT * FROM employees WHERE position = 'Manager';

Update

UPDATE employees SET salary = 80000 WHERE name = 'Jane Smith';

Delete

DELETE FROM employees WHERE id = 3;


🎯 Importance of CRUD for Business Analysts

Reason

Explanation

Understand Data Flow

BAs need to know how data is created, accessed, updated, and deleted.

Requirement Specification

Accurately define system requirements related to data management.

Data Validation and Analysis

Ensure that the data aligns with business needs and integrity.

Communicate with Developers

Specify how data operations should be handled in the system.

User Story Creation in Agile

Describe data manipulation needs in user stories.


🚀 Summary

CRUD Operation

Action

SQL Command

Create

Add new data

INSERT

Read

Retrieve and display data

SELECT

Update

Modify existing data

UPDATE

Delete

Remove data

DELETE

Last updated