DBMS lab manual final 2022 scheme
DBMS lab manual final 2022 scheme
USE COMPANY
2. Insert the any three records in the employee table contains attributes EMPNO, ENAME
JOB, MANAGER_NO, SAL, COMMISSION and use rollback. Check the result.
START TRANSACTION
INSERT INTO Employee (EMPNO, ENAME, JOB, MANAGER_NO, SAL, COMMISSION)
VALUES (1, 'Kavana Shetty', 'Manager', NULL, 5000.00, 1000.00);
COMMIT;
1
Database Management System (BCS403)
3. Add primary key constraint and not null constraint to the employee table.
ALTER TABLE Employee
ADD CONSTRAINT pk_employee PRIMARY KEY (EMPNO);
DESC Employee;
4. Insert null values to the employee table and verify the result.
ALTER TABLE Employee
MODIFY ENAME VARCHAR(255) NOT NULL,
MODIFY JOB VARCHAR(255) NOT NULL,
MODIFY SAL DECIMAL(10, 2) NOT NULL;
2
Database Management System (BCS403)
2. Create a table called Employee that contain attributes EMPNO, ENAME, JOB, MGR, SAL
& execute the following.
Add a column commission with domain to the Employee table.
Insert any five records into the table.
Update the column details of job
Rename the column of Employ table using alter command.
Delete the employee whose Empno is 105.
3
Database Management System (BCS403)
4
Database Management System (BCS403)
Create Employee table containing all Records E_id, E_name, Age, Salary.
Create database lab3;
use lab3;
create table emp(E_id int,E_name varchar(10),Age int,Salary int);
desc emp;
INSERT INTO emp(E_id,E_name,Age,Salary) VALUES (101,'Kavana',30, 5000.00);
INSERT INTO emp(E_id,E_name,Age,Salary) VALUES (102,'Patil',35, 7000.00);
INSERT INTO emp(E_id,E_name,Age,Salary) VALUES (103,'Ranjitha',22,25000.00);
INSERT INTO emp(E_id,E_name,Age,Salary) VALUES (104,'Ram',36,42000.00);
INSERT INTO emp(E_id,E_name,Age,Salary) VALUES (105,'Naveen',30,5000.00);
Select * from emp;
5
Database Management System (BCS403)
4. Create a row level trigger for the customers table that would fire for INSERT or UPDATE
or DELETE operations performed on the CUSTOMERS table. This trigger will display
the salary difference between the old & new Salary.
CUSTOMERS(ID,NAME,AGE,ADDRESS,SALARY)
-- INSERT TRIGGER
DELIMITER //
DELIMITER ;
-- UPDATE TRIGGER
DELIMITER //
6
Database Management System (BCS403)
END;//
DELIMITER ;
-- DELETE TRIGGER
DELIMITER //
DELIMITER ;
7
Database Management System (BCS403)
5. Create cursor for Employee table & extract the values from the table. Declare the variables,
Open the cursor & extract the values from the cursor. Close the cursor.
CUSTOMERS(ID,NAME,AGE,ADDRESS,SALARY)
USE lab05;
DELIMITER //
8
Database Management System (BCS403)
DELIMITER ;
CALL fetch_employee_data();
9
Database Management System (BCS403)
6. Write a PL/SQL block of code using parameterized Cursor that will merge the data
available in the newly created table N_RollCall with the data available in the table
O_RollCall. If the data in the first table already exist in the second table then that data
should be skipped.
CREATE DATABASE ROLLCALL;
USE ROLLCALL;
10
Database Management System (BCS403)
DELIMITER //
11
Database Management System (BCS403)
DELIMITER ;
12
Database Management System (BCS403)
7. Install an Open Source NoSQL Data base MongoDB & perform basic CRUD(Create, Read,
Update & Delete) operations. Execute MongoDB basic Queries using CRUD operations.
5. INSERT operations
Insert 5 Documents into the ProgrammingBooks Collection :
bookDB> db.ProgrammingBooks.insertMany([
{
title: "Clean Code: A Handbook of Agile Software Craftsmanship",
author: "Robert C. Martin",
category: "Software Development",
year: 2008
},
{
title: "JavaScript: The Good Parts",
author: "Douglas Crockford",
category: "JavaScript",
13
Database Management System (BCS403)
year: 2008
},
{
title: "Design Patterns: Elements of Reusable Object-Oriented Software",
author: "Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides",
category: "Software Design",
year: 1994
},
{
title: "Introduction to Algorithms",
author: "Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, Clifford Stein",
category: "Algorithms",
year: 1990
},
{
title: "Python Crash Course: A Hands-On, Project-Based Introduction to Programming",
author: "Eric Matthes",
category: "Python",
year: 2015
}
])
14
Database Management System (BCS403)
_id: ObjectId('663eaaebae582498972202df'),
title: 'Clean Code: A Handbook of Agile Software Craftsmanship',
author: 'Robert C. Martin',
category: 'Software Development',
year: 2008
},
{
_id: ObjectId('663eaaebae582498972202e0'),
title: 'JavaScript: The Good Parts',
author: 'Douglas Crockford',
category: 'JavaScript',
year: 2008
},
{
_id: ObjectId('663eaaebae582498972202e1'),
title: 'Design Patterns: Elements of Reusable Object-Oriented Software',
author: 'Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides',
category: 'Software Design',
year: 1994
},
{
_id: ObjectId('663eaaebae582498972202e2'),
title: 'Introduction to Algorithms',
author: 'Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, Clifford Stein',
category: 'Algorithms',
year: 1990
},
{
_id: ObjectId('663eaaebae582498972202e3'),
title: 'Python Crash Course: A Hands-On, Project-Based Introduction to Programming',
author: 'Eric Matthes',
category: 'Python',
year: 2015
},
{
15
Database Management System (BCS403)
_id: ObjectId('663eab05ae582498972202e4'),
title: 'The Pragmatic Programmer: Your Journey to Mastery',
author: 'David Thomas, Andrew Hunt',
category: 'Software Development',
year: 1999
}
]
16
Database Management System (BCS403)
7. Update Operations
Update a Single Document
bookDB>db.ProgrammingBooks.updateOne(
{ title: "Clean Code: A Handbook of Agile Software Craftsmanship" },
{ $set: { author: "Robert C. Martin (Uncle Bob)" } }
)
//verify the update operation by displaying books published before year 2010
bookDB> db.ProgrammingBooks.find({ year: { $lt: 2010 } }).pretty()
[
17
Database Management System (BCS403)
{
_id: ObjectId('663eaaebae582498972202df'),
title: 'Clean Code: A Handbook of Agile Software Craftsmanship',
author: 'Robert C. Martin (Uncle Bob)',
category: 'Classic Programming Books',
year: 2008
},
{
_id: ObjectId('663eaaebae582498972202e0'),
title: 'JavaScript: The Good Parts',
author: 'Douglas Crockford',
category: 'Classic Programming Books',
year: 2008
},
{
_id: ObjectId('663eaaebae582498972202e1'),
title: 'Design Patterns: Elements of Reusable Object-Oriented Software',
author: 'Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides',
category: 'Classic Programming Books',
year: 1994
},
{
_id: ObjectId('663eaaebae582498972202e2'),
title: 'Introduction to Algorithms',
author: 'Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, Clifford Stein',
category: 'Classic Programming Books',
year: 1990
},
{
_id: ObjectId('663eab05ae582498972202e4'),
title: 'The Pragmatic Programmer: Your Journey to Mastery',
author: 'David Thomas, Andrew Hunt',
category: 'Classic Programming Books',
year: 1999
}
18
Database Management System (BCS403)
8. Delete Operations
Delete a Single Document
bookDB> db.ProgrammingBooks.deleteOne({ title: "JavaScript: The Good Parts" })
{ acknowledged: true, deletedCount: 1 }
bookDB> db.ProgrammingBooks.drop()
true
bookDB>
19