Walchand College Of Engineering, Sangli
Department of Computer Science and Engineering
Name: Aryan Mukund Jadhav
PRN: 245100121
Subject: DataBase Engineering Lab
Class: S.Y CSE(Aided)
Batch: CSA-5
ASSIGNMENT-4
Q. Perform insertion, deletion, and updating of tuples using SQL DML commands.
A relational database has been created for the selected case study system. The required tables
have already been defined using SQL DDL statements and contain appropriate primary keys,
foreign keys, and integrity constraints.
Your task is to manipulate the data stored in these tables using SQL Data Manipulation
Language
(DML) commands.
Tasks to Perform
1. Insertion Operations
Perform INSERT operations such as:
∙ Add new master records (e.g., users/customers/students/products/flights).
∙ Insert related records into dependent tables.
∙ Insert multiple records in a single statement.
∙ Insert records with partial attribute values where allowed.
Add new master record:
INSERT INTO Users (f_name, l_name, email, contact, DOB, gender, PWD)
VALUES
('Rohit', 'Sharma', 'rohit@[Link]', '9876501234', '2002-03-15', 'Male', FALSE);
Insert Related Records Into Dependent Tables:
Walchand College Of Engineering, Sangli
Department of Computer Science and Engineering
INSERT INTO Class (train_no, class_type, fare)
VALUES
(101, 'Sleeper', 500.00);
Insert Multiple Records in One Statement:
INSERT INTO Users (f_name, l_name, email, contact, DOB, gender, PWD)
VALUES
('Amit', 'Patil', 'amit@[Link]', '9876543211', '2002-04-10', 'Male', FALSE),
('Sneha', 'Kulkarni', 'sneha@[Link]', '9876543212', '2003-06-21', 'Female',
FALSE),
('Raj', 'Shinde', 'raj@[Link]', '9876543213', '2001-09-12', 'Male', TRUE);
Update Operations
Perform UPDATE operations such as:
∙ Modify attribute values for existing records.
∙ Update multiple attributes in a single query.
∙ Apply conditional updates using WHERE clause.
Walchand College Of Engineering, Sangli
Department of Computer Science and Engineering
Modify Attribute Values for Existing Records:
UPDATE Users
SET contact = '9999999999'
WHERE user_id = 1;
Update multiple attributes in a single query:
UPDATE Users
SET email = 'amit_new@[Link]',
contact = '8888888888'
WHERE user_id = 2;
Apply Conditional Updates Using WHERE Clause:
UPDATE Users
Walchand College Of Engineering, Sangli
Department of Computer Science and Engineering
SET contact = '9999999999'
WHERE user_id = 1;
Deletion Operations
Perform DELETE operations such as:
∙ Delete specific records using conditions.
∙ Remove dependent records while preserving referential integrity.
Delete Specific Records Using Conditions:
DELETE FROM Users
WHERE user_id = 3;
Walchand College Of Engineering, Sangli
Department of Computer Science and Engineering
Remove Dependent Records While Preserving Referential
Integrity:
DELETE FROM Users
WHERE user_id = 1;