0% found this document useful (0 votes)
9 views2 pages

CRUD Operations With Examples

CRUD stands for Create, Read, Update, and Delete, which are the fundamental operations for managing data in databases. The document provides examples of CRUD operations using a student database in both SQL and Python dictionary formats. It emphasizes the importance of CRUD in relational databases and backend development.

Uploaded by

Shruti Verma
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

CRUD Operations With Examples

CRUD stands for Create, Read, Update, and Delete, which are the fundamental operations for managing data in databases. The document provides examples of CRUD operations using a student database in both SQL and Python dictionary formats. It emphasizes the importance of CRUD in relational databases and backend development.

Uploaded by

Shruti Verma
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

CRUD Operations – Explained with Examples

1. What is CRUD?

CRUD stands for Create, Read, Update, and Delete — the four basic operations that can
be performed on data in any storage system, especially databases.

C - Create: Add new data

R - Read: Retrieve existing data

U - Update: Modify existing data

D - Delete: Remove data

2. Real-World Example: Student Database

We manage a student record system with the following fields:

- id (primary key)

- name

- age

- course

SQL Implementation (MySQL/PostgreSQL)


 CREATE

INSERT INTO students (id, name, age, course)


VALUES (1, 'Alice', 20, 'Computer Science');

 READ

SELECT * FROM students;


SELECT * FROM students WHERE id = 1;

 UPDATE

UPDATE students
SET age = 21
WHERE id = 1;
 DELETE

DELETE FROM students WHERE id = 1;


Python Dictionary-Based Example

# Sample database (dictionary)


students = {}

# 1. CREATE
students[1] = {'name': 'Alice', 'age': 20, 'course': 'Computer Science'}

# 2. READ
print("All students:", students)
print("Student ID 1:", [Link](1))

# 3. UPDATE
students[1]['age'] = 21
print("Updated student ID 1:", students[1])

# 4. DELETE
del students[1]
print("After deletion:", students)

Key Points

- SQL CRUD is used in relational databases.

- Python CRUD can be done with dictionaries or ORM libraries.

- CRUD operations form the foundation of backend development and REST APIs.

You might also like