DBMS Master Manual BCS403 - Final
DBMS Master Manual BCS403 - Final
MASTER MANUAL
Course: DBMS LABORATORY
IV-SEMESTER
Prepared by:
Mrs. Vidya Myageri
Assistant Professor
Department of Computer Science & Engineering, AJIET, Mangalore
M2: To provide an inspirational atmosphere in the department to nurture research and innovation
capabilities among students and faculties making them good innovators and visionaries.
M3: To Establish a vibrant Industry-Academic relationships and collaborations among the individuals
having the opportunities to work on the latest technologies and professional challenges with integrity.
M4: To Cultivate students with professional skills, foster innovative research endeavors, and
cultivate entrepreneurial capabilities.
Page | 2
Database Management System BCS403
PEO2: To mould students, to have a successful career in the IT industry where graduates will
be able to design and implement the needs of society and nation.
PEO3: To transform students, to excel in a competitive world through higher education and
indulge in research through continuous learning process
Page | 3
Database Management System BCS403
Do's
1. Maintain discipline in the Laboratory.
2. Before entering the Laboratory, keep the footwear on the shoe rack.
3. Proper dress code has to be maintained while entering the Laboratory.
4. Students should carry a lab observation book, student manual and record book completed in
all aspects.
5. Read and understand the logic of the program thoroughly before coming to the laboratory.
6. Enter the login book before switching on the computer.
7. Enter your batch member names and other details in the slips for hardware kits.
8. Students should be at their concerned places; unnecessary movement is restricted.
9. Students should maintain the same computer until the end of the semester.
10. Report any problems in computers/hardware kits to the faculty member in-charge/laboratory
technician immediately.
11. The practical result should be noted down into their observation and the result must be shown
to the faculty member in-charge for verification.
12. After completing the experiments, students should switch off the computers, enter logout
time, return the hardware kits and keep the chairs properly.
Don'ts
1. Do not come late to the Laboratory.
2. Do not enter the laboratory without an ID card, lab dress code, observation book and record.
3. Do not leave the laboratory without the permission of the faculty in-charge.
4. Never eat, drink while working in the laboratory.
5. Do not handle any equipment before reading the instructions/instruction manuals.
6. Do not exchange the computers with others and hardware kits also.
7. Do not misbehave in the laboratory.
8. Do not alter computer settings/software settings.
9. External Disk/drives should not be connected to computers without permission, doing so
will attract fines.
10. Do not remove anything from the kits/experimental set up without permission. Doing so will
attract fines.
11. Do not mishandle the equipment / Computers.
12. Do not leave the laboratory without verification of hardware kits by the lab instructor.
13. Usage of Mobile phones, tablets and other portable devices are not allowed in restricted
places.
Page | 4
Database Management System BCS403
INSTRUCTIONS TO STUDENTS
● Students must bring Observation book, record and manual along with pen, pencil, and eraser etc.,
no borrowing from others.
● Students must handle the trainer kit and other components carefully, as they are expensive.
● Before switch on the trainer kit, must show the connections to one of the faculties or instructors.
● After the completion of the experiment should return the components to the respective lab
instructors.
● Before leaving the lab, should check whether they have switch off the power supplies and keep
their chairs properly.
● Be regular to the Lab Do not come late to the Lab
● Do not throw connecting wires on the Floor
● Wear your College ID card Do not operate the IC trainer kits without permission
● Avoid unnecessary talking while doing the experiment
● Avoid loose connection and short circuits
● Take the signature of the lab in charge before taking the components
● Do not interchange the ICs while doing the experiment
● Handle the trainer kit properly
● Do not panic if you do not get the output
● Keep your work area clean after completing the experiment.
● After completion of the experiment switch off the power and return the components
● Arrange your chairs and tables before leaving.
Page | 5
Database Management System BCS403
● Put your name, USN and subject on the outside front cover of the record. Put that
same information on the first page inside.
● Update Table of Contents every time you start each new experiment or topic
● Always use pen and write neatly and clearly
● Start each new topic (experiment, notes, calculation, etc.) on a right-side (odd numbered) page
● Obvious care should be taken to make it readable, even if you have bad handwriting
● Date to be written every page on the top right side corner
● On each right-side page
⮚ Title of experiment
⮚ Aim/Objectives
⮚ Components Required
⮚ Theory
⮚ Procedure described clearly in steps
⮚ Result
● On each left side page
⮚ Pin diagrams
⮚ Circuit diagram
⮚ Tables
⮚ Graphs
● Use labels and captions for figures and tables
● Attach printouts and plots of data as needed. Stick printouts (A4 Size) on the right
ide of the lab record
Page | 6
Database Management System Lab BCS403
SYLLABUS
DBMS LABORATORY WITH MINI PROJECT
[As per Choice Based Credit System (CBCS) scheme] (Effective
from the academic year 2023 -2024) SEMESTER – IV
Teaching-Learning Process
These are sample Strategies, which teachers can use to accelerate the attainment of the various course
outcomes.
1. Lecturer method (L) needs not to be only a traditional lecture method, but alternative effective
teaching methods could be adopted to attain the outcomes.
2. Use of Video/Animation to explain functioning of various concepts.
3. Encourage collaborative (Group Learning) Learning in the class.
4. Ask at least three HOT (Higher order Thinking) questions in the class, which promotes critical
thinking.
5. Adopt Problem Based Learning (PBL), which fosters students’ Analytical skills, develop design
thinking skills such as the ability to design, evaluate, generalize, and analyze information rather than
simply recall it.
6. Introduce Topics in manifold representations.
7. Show the different ways to solve the same problem with different circuits/logic and
encourage the students to come up with their own creative ways to solve them.
8. Discuss how every concept can be applied to the real world - and when that's possible, it helps
improve the students' understanding
9. Use any of these methods: Chalk and board, Active Learning, Case Studies
MODULE1.
Laboratory Component
Page | 7
Database Management System Lab BCS403
Page | 8
Database Management System Lab BCS403
Page | 9
Database Management System Lab BCS403
IPCC
DATABASE MANAGEMENT
SYSTEM [BCS403]
Page | 10
Database Management System BCS403
Page | 3
Database Management System BCS403
● The sum of two tests, two assignments, and practical sessions will be out of 50 marks and will
CIE methods /question paper has to be designed to attain the different levels of Bloom’s
taxonomy as per the outcome defined for the course
● Theory SEE will be conducted by University as per the scheduled timetable, with common
question papers for the subject (duration 03 hours)
1. The question paper will have ten questions. Each question is set for 20 marks.
2. There will be 2 questions from each module. Each of the two questions under a module
(with a maximum of 3 sub-questions), should have a mix of topics under that module.
● The students have to answer 5 full questions, selecting one full question from each module
Page | 4
Database Management System BCS403
Page | 5
Database Management System BCS403
2 UPS 20KVA 1
4 Internet 150mbps 1
Page | 6
Database Management System BCS403
INTRODUCTION TO ORACLE
SQL
SQL stands for Structured Query Language. SQL is used to create, remove, alter the
database and database objects
in a database management system and to store, retrieve, update the data in a database.
SQL is a standard language
for creating, accessing, manipulating database management system. SQL works for all
modern relational database
management systems, like SQL Server, Oracle, MySQL, etc.
SQL commands can be categorized into five categories based on their functionality
SQL commands can be categorized into five categories based on their functionality
);
Suppose, you want to create a Student table with five columns in the SQL
database. To do this, you have to write the following DDL command:
Example 1:
CREATE TABLE Student
(
Roll_No. int ,
First_Name varchar (20) ,
Last_Name varchar (20) ,
Age int ,
Marks int,
Dob Date
);
SQL>desc Student;
Example 2:
create table Employee
(
empid varchar(10),
empname varchar(20) ,
gender varchar(7),
age number(3),
dept varchar(15) ,
doj Date
);
SQL> desc Employee
Example 3:
create table BOOK
(
Book_id varchar(4),
Title varchar(10),
Publisher_name varchar(10),
Pub_year int
);
SQL> desc BOOK;
2.ALTER
This command is used to add, delete or change columns in the existing table. The
user needs to know the existing table name and can do add, delete or modify tasks
easily.
Syntax: –
.ADD:
SQL> alter table employee add(designation varchar(15));
Table altered.
II.MODIFY
SQL> alter table employee modify (designation varchar(20));
Table altered
Example 1:
ALTER TABLE Student
ADD CGPA number;
SQL>desc Student;
Example 2:
ALTER TABLE Employee
ADD Salary number;
SQL>desc Employee;
Example 3:
ALTER TABLE BOOK
ADD Author_nmae varchar(20);
SQL>desc Student;
3. RENAME:
It is possible to change name of table with or without data in it using simple
RENAME command.
We can rename any table object at any point of time.
Syntax –
RENAME <Table Name> To <New_Table_Name>;
Example:
RENAME TABLE Employee To EMP;
4.TRUNCAT:
This command is used to remove all rows from the table, but the structure of the
table still exists.
Syntax –
Syntax to remove an existing table.
Example:
TRUNCATE TABLE Student;
5. DROP
This command is used to remove an existing table along with its structure from
the Database.
Syntax –
Syntax to drop an existing table.
DROP TABLE table_name;
Example: DROP TABLE Student_info;
DML(DATA MANIPULATION LANGUAGE):
Data manipulation language allows the users to query and manipulate data in
existing schema in object.
It allows following data to insert, delete, update and recovery data in schema
object.
DML COMMANDS:
❖ INSERT
❖ UPDATE
❖ DELETE
1.INSERT
This command is used to enter the information or values into a row. We can
connect one or more records to a single table within a repository using this
instruction.
Syntax:
Insert into Table_ Name Values(column1, column2, ....);
Example:
CREATE TABLE Student
(
Roll_No int ,
First_Name varchar (20) ,
Last_Name varchar (20) ,
Marks int,
Dob Date
);
SQL>desc Student;
SQL> insert into Student values(‘01’,’Adit,’k’’,25,’11-02-2004’);
SQL> insert into Student values(02,“Arpitha”,”S”, 20,’21-12-2003’);
SQL> insert into Student values(03,“Jorge”,”D”, 20, 18,’10-08-2001’);
Insert 2 more rows.
SQL>desc Student;
2.UPDATE
This allows the user to update the particular column value using the where
clause condition. This command is used to alter existing table records.
Syntax:
UPDATE <table_ name>
SET <column_ name = value>
WHERE condition;
Example:
UPDATE Students
SET Marks= 21
WHERE First_ name = “Arpitha”;
SQL>desc Students;
3. DELETE
a) Delete some rows
DELETE statement is used to delete rows from a table. Generally DELETE
statement removes one or more records from a table.
Syntax:
DELETE FROM table_name WHERE condition;
Example:
Delete from Students where Roll_no=’111’;
Example:
Select * from Students;
SQL> desc Students;
Example:
SELECT DISTINCT Roll_No FROM Students;
Example:
SELECT * FROM students
WHERE students_name IN ( Arpitha, Jorge);
Example:
SELECT * FROM student WHERE mark BETWEEN 80 and 100;
6.Renaming:
The select statement can be used to rename either a column or the entire table.
Syntax:
Renaming a column:
SELECT column name AS new name FROM table_name;
Example:
Renaming a table:
Example:
RENAME Student TO Stu_details;
7.SELECT DATE
It is used to retrieve a date from a database. If you want to find a particular date
from a database, you can use this statement.
Syntax:
SELECT Column_Names(S) from table-name
WHERE condition(date_column);
8. SELECT NULL
Null values are used to represent missing unknown data.
There can be two conditions:
Syntax:
SELECT COLUMN_NAME(S) FROM TABLE_NAME
WHERE COLUMN_NAME IS NOT NULL;
Example:
SELECT Student_name, Marks FROM STUDENTS
WHERE MARKS IS NOT NULL;
ORDER BY Clause
ORDER BY is a clause in SQL which shows the result-set of the SELECT statement
in either ascending or descending order.
a) with one row
Syntax:
SELECT Column_Name FROM Table_Name
ORDER BY Column_Name;
Example:
SELECT * FROM Students ORDER BY Reg_no;
GROUP BY clause
GROUP BY is an SQL keyword used in the SELECT query for arranging the same
values of a column in the group by using SQL functions.
Syntax:
SELECT Column_Name(S) FROM Table_Name
GROUP BY Column_Name(S);
Example:
SELECT COUNT (marks), Student_name GROUP BY marks;
c) COUNT() Function
The COUNT() function returns the number of rows in a database table.
Syntax:
COUNT(*)
or
COUNT( [ALL|DISTINCT] expression )
Example:
1. SELECT COUNT(*)
FROM Student;
2. SELECT COUNT(Marks)
FROM Student
GROUP BY marks
HAVING COUNT(*) > 50;
d) SUM() clause
It is used to return the total summed value of an expression.
Syntax:
SELECT SUM(aggregate_expression)
FROM tables
[WHERE conditions];
Example:
SELECT SUM(Marks)
FROM Student
Where roll_no=’111’;
GRANT
used to provide access right to the user.
REVOKE
REVOKE command is used to take back access right from the user, it cancels
access right of the user from the
database object.
Syntax
REVOKE ALL ON Employee FROM user;
TCL commands can rollback and commit data modification in the database. The
most used TCL commands are COMMIT, ROLLBACK, SAVEPOINT, and SET
TRANSACTION.
COMMIT
COMMIT command is used to save or apply the modification in the database.
ROLLBACK
ROLLBACK command is used to undo the modification.
SAVEPOINT
SAVEPOINT command is used to temporarily save a transaction, the transaction
can roll back to this point when it's needed.
Syntax :
Just write COMMIT or ROLLBACK or SAVEPOINT
Solutions:
Create a table employee with the given constraints:
SQL> create table employee (empno number,ename varchar2(10), job
varchar2(10),mgr
number,sal number);
SQL> create table employee (empno number,
ename varchar(10),
job varchar(10),
mgr_no number,
sal number,
commission number );
Table created
SQL>desc employee;
Solutions:
//create user
User created.
Grant succeeded.
Connect c##dbms/dbms403;
Connected.
Show user;
2. Insert the any three records in the employee table and use rollback.
Check the result
SQL>rollback
Rollback completed
3. Add primary key constraint and not null constraint to the employee
table.
SQL>desc Employee;
4. Insert null values to the employee table and verify the result.
1 row inserted
Viva Question:
1. What is data?
Data is a collection of information gathered by observations, measurements,
research or analysis.
2. What is database?
A database is an electronically stored, systematic collection of data. It can contain
any type of data, including words, numbers, images, videos, and files.
3. What is DBMS?
Database Management Systems (DBMS) are software systems used to store,
retrieve, and run queries on data.
7. What is Table?
A table is an arrangement of data in rows and columns, or possibly in a more
complex structure.
8. What is a Tuple?
A tuple is an ordered sequence of values. The values can be repeated, but their
number is always finite.
9. What is Columns?
column or pillar in architecture and structural engineering is a structural element
that transmits, through compression, the weight of the structure above to other
structural elements below.
Experiment-2
Solution:
Table altered.
1 row updated.
Table altered.
SQL>desc employee;
1 row deleted
Viva Questions
1. What is an Attribute?
A quality, character, or characteristic ascribed to someone or something has
leadership attributes.
Experiment-3
Solution:
1. Create Employee table containing all Records E_id, E_name, Age, Salary.
SQL>desc Employee;
Viva Questions
1. What is an Attribute?
A table consists of several records(row), each record can be broken down into
several smaller parts of data known as Attributes. The above Employee table
consist of four attributes, ID, Name, Age and Salary.
These are attributes other than candidate key attributes in a table. For example
Firstname is a non key attribute as it does not represent the main characteristics of
the entity.
Experiment 4:
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)
Solution:
1. Create Customer Table:
Table created.
3.Creating trigger
Trigger created.
Previous salary:8000
Current salary: 10000
Salary difference:2000
Viva Questions
A primary key is a column whose values uniquely identify every row in a table.
When a "one" table's primary key field is added to a related "many" table in
order to create the common field which relates the two tables, it is called a
foreign key in the "many" table.
For example, the salary of an employee is stored in salary table. The relation is
established via foreign key column “Employee_ID_Ref” which refers
“Employee_ID” field in the Employee table.
6. What is a query?
A query with respect to DBMS relates to user commands that are used to interact
with a data base. The query language can be classified into data definition
language and data manipulation language.
SQL Update is used to update data in a row or set of rows specified in the filter
condition.
SQL Delete is used to delete a row or set of rows specified in the filter condition.
ORDER BY clause helps to sort the data in either ascending order to descending
Experiment-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. Employee(E_id, E_name, Age, Salary)
Solution:
Table created.
3. Create the cursor ,extracting the value from Employee table and close
the cursor.
Output:
Viva Questions
1. Define Normalization.
Organized data void of inconsistent dependency and redundancy within a database is
called normalization.
2. Enlist the advantages of normalizing database.
Advantages of normalizing database are:
• No duplicate entries
• Saves storage space
• Boasts the query performances.
3. What is Entity?
An entity can be a real-world object, either animate or inanimate, that can be easily
identifiable. For example, in a school database, students, teachers, classes, and courses
offered can be considered as entities.
5. What is Relationship?
The association among entities is called a relationship. For example, an
employee works_at a department, a student enrolls in a course. Here, Works_at and
Enrolls are called relationships.
• Binary = degree 2
• Ternary = degree 3
• n-ary = degree n
Experiment-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.
Solution:
Procedure created.
SQL>call roll_details();
Call completed.
Viva Questions
7. What is DDL?
DDL stands for Data Definition Language. SQL queries like CREATE,
ALTER, DROP and RENAME come under this.
8. What
is DML?
DML stands for Data Manipulation Language. SQL queries like SELECT,
INSERT and UPDATE come under this.
9. What is
DCL?
DCL stands for Data Control Language. SQL queries like GRANT and
REVOKE come under this.
Experiment-7:
Install an Open Source NoSQL Data base MangoDB & perform basic
CRUD(Create, Read,Update & Delete) operations. Execute MangoDB basic
Queries using CRUD operations.
MongoDB is a popular NoSQL database offering flexibility, scalability, and ease of use. Installing
and configuring MongoDB in Ubuntu is a straightforward process, but it requires careful attention to
detail to ensure a smooth setup.
In this guide, we’ll learn how to install and configure MongoDB in Ubuntu. We’ll walk you through
each step, from installation to configuration, enabling you to harness the power of MongoDB on
your Ubuntu system.
Let’s look at the requirements for installing MongoDB in Ubuntu.
MongoDB can be installed on Ubuntu with the use of the following commands. These commands
are easy to run on the terminal and make the installation process handy. Follow the steps given
below to install MongoDB:
Step 1: First you need to update and upgrade your system repository to install MongoDB. Type the
following command in your terminal and then press Enter.
Step 2: Now, install the MongoDB package using ‘apt‘. Type the following command and press
Enter.
Step 3: Check the service status for MongoDB with the help of following command:
Step 4: Now check if the installation process is done correctly and everything is working fine. Go
through the following command:
the value “1” in ok field indicates that the server is working properly with no errors.
Step 5: MongoDB services can be started and stopped with the use of following commands: To stop
running the MongoDB service, use command :
MongoDB provides a command-line interface called the MongoDB shell, which allows you to
interact with the database.
To access the MongoDB shell, simply type the following command in your terminal:
mongo
You are now connected to the MongoDB server, and you can start executing commands
to create databases, collections, and documents.
CRUD Operations:
1. Create (Insert)
To create or insert data into a MongoDB collection, you use the insertOne() or
insertMany() methods.
2. Read (Query)
To read or retrieve data from a MongoDB collection, you use the find() method.
db.collection('yourCollection').find();
3. Update
To update existing documents in a MongoDB collection, you use the updateOne() or updateMany()
methods.
db.collection('yourCollection').updateOne(
);
db.collection('yourCollection').updateMany(
);
4. Delete
To delete documents from a MongoDB collection, you use the deleteOne() or deleteMany() methods.
CRUD is the acronym for CREATE, READ, UPDATE and DELETE. These terms describe the
four essential operations for creating and managing persistentdata elements, mainly in relational
and NoSQL databases.
You can perform update, insert and delete operation in the Grid. While performingthese
operations, the corresponding event is invoked. In that event SQL query is used to update the
database. The events for performing CRUD operation are declared.
The MongoDB shell provides the following methods to update documents in acollection:
1. To update a single document, use db. collection. updateOne() .
2. To update multiple documents, use db. collection. updateMany() .
3. To replace a document, use db. collection. replaceOne() .
The basic methods of interacting with a MongoDB server are called CRUD operations. CRUD
stands for Create, Read, Update, and Delete. These CRUDmethods are the primary ways you will
manage the data in your databases.
CRUD stands for Create, Read, Update, and Delete. These are the four fundamental operations
of persistent storage. In the context of RESTful APIs , they correspond to the HTTP methods
POST, GET, PUT/PATCH, and DELETE.
Several ways can be employed to create and remove collections in MongoDB. Of which one
way is by using db. Create Collection (name, options). MongoDB creates a collection for an
inserted command automatically if no similar collectionalready exists in the MongoDB
database.