DBMS - Manual (bcs403)
DBMS - Manual (bcs403)
DEPARTMENT OF
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING
Semester: Batch:
DBMS LABORATORY(BCS403)
Program Outcomes
DEP OF AIML,KNSIT 1
DBMS LABORATORY(BCS403)
Course Overview
DEP OF AIML,KNSIT 2
DBMS LABORATORY(BCS403)
SYLLABUS
DATABASE MANAGEMENT SYSTEM Semester 4
Course Code BCS403 CIE Marks 50
Teaching Hours/Week (L:T:P: S) 3:0:2:0 SEE Marks 50
Total Hours of Pedagogy 40 hours Theory + 8-10 Lab slots Total Marks 100
Credits 04 Exam Hours
Examination nature (SEE) Theory
Course objectives:
● To Provide a strong foundation in database concepts, technology, and practice.
● To Practice SQL programming through a variety of database problems.
● To Understand the relational database design principles.
● To Demonstrate the use of concurrency and transactions in database.
● To Design and build database applications for real world problems.
● To become familiar with database storage structures and access techniques.
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
Sl.NO Experiments
1 Create a table called Employee & execute the following.
Employee(EMPNO,ENAME,JOB, MANAGER_NO, SAL, COMMISSION)
1. Create a user and grant all permissions to theuser.
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.
3. Add primary key constraint and not null constraint to the employee table.
4. Insert null values to the employee table and verify the result.
DEP OF AIML,KNSIT 3
DBMS LABORATORY(BCS403)
2 Create a table called Employee that contain attributes EMPNO,ENAME,JOB, MGR,SAL &
execute the following.
1. Add a column commission with domain to the Employeetable.
2. Insert any five records into the table.
3. Update the column details of job
4. Rename the column of Employ table using alter command.
5. Delete the employee whose Empno is 105.
3 Queries using aggregate functions(COUNT,AVG,MIN,MAX,SUM),Group by,Orderby.
Employee(E_id, E_name, Age, Salary)
1. Create Employee table containing all Records E_id, E_name, Age, Salary.
2. Count number of employee names from employeetable
3. Find the Maximum age from employee table.
4. Find the Minimum age from employeetable.
5. Find salaries of employee in Ascending Order.
6. Find grouped salaries of employees.
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)
5 Create cursor for Employee table & extract the values from the table. Declare the variables
,Open the cursor & extrct the values from the cursor. Close the cursor.
Employee(E_id, E_name, Age, Salary)
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.
7 Install an Open Source NoSQL Data base MangoDB & perform basic CRUD(Create, Read,
Update & Delete) operations. Execute MangoDB basic Queries using CRUD operations.
Course outcomes (Course Skill Set):
At the end of the course, the student will be able to:
● Describe the basic elements of a relational database management system
● Design entity relationship for the given scenario.
● Apply various Structured Query Language (SQL) statements for database manipulation.
● Analyse various normalization forms for the given application.
● Develop database applications for the given real world problem.
● Understand the concepts related to NoSQL databases.
Assessment Details (both CIE and SEE)
The weightage of Continuous Internal Evaluation (CIE) is 50% and for Semester End Exam (SEE) is 50%. The minimum
DEP OF AIML,KNSIT 4
DBMS LABORATORY(BCS403)
SQL stands for “Structured Query Language” and can be pronounced as “SQL” or “sequel
– (Structured English Query Language)”. It is a query language used for accessing and modifying
information in the database. IBM first developed SQL in 1970s. Also it is an ANSI/ISO standard.
It has become a Standard Universal Language used by most of the relationaldatabase management
systems (RDBMS). Some of the RDBMS systems are: Oracle, Microsoft SQL server, Sybase etc.
Most of these have provided their own implementation thus enhancing its feature and making it a
powerful tool. Few of the SQL commands used in SQL programming are SELECT Statement,
UPDATE Statement, INSERT INTO Statement, DELETE Statement, WHERE Clause, ORDER
BY Clause, GROUP BY Clause, ORDER Clause, Joins, Views,GROUP Functions, Indexes etc.
SQL Commands
SQL commands are instructions used to communicate with the database to performspecific
task that work with data. SQL commands can be used not only for searching the database but also
to perform various other functions like, for example, you can create tables, add data to tables, or
modify data, drop the table, set permissions for users.
CREATE TABLE Statement
The CREATE TABLE Statement is used to create tables to store data. Integrity Constraints like
primary key, unique key and foreign key can be defined for the columns while creating the table. The
integrity constraints can be defined at column level or table level. The implementation and the syntax
of the CREATE Statements differs for different RDBMS.
CREATE TABLE
table_name
column_name2 datatype,...
column_nameNdatatype);
DEP OF AIML,KNSIT 5
DBMS LABORATORY(BCS403)
char(size) Fixed-length character string. Size is specified in parenthesis. Max 255 bytes.
or int
Date Date value in „dd-mon-yy‟. Eg., ‟07-jul-2004‟
number(size Number value with a maximum number of digits of "size" total, with a
d) or real maximum number of "d" digits to the right of the decimal.
column_name2,..)
DEP OF AIML,KNSIT 6
DBMS LABORATORY(BCS403)
referenced_table_name(column_name)
4) Unique Key:
This constraint ensures that a column or a group of columns in each row have a distinct value.
A column(s) can have a null value but the values cannot be duplicated.
Syntax to define a Unique key at column level:
[CONSTRAINT constraint_name] UNIQUE
5) Check Constraint:
This constraint defines a business rule on a column. All the rows must satisfy this rule. The
constraint can be applied for a single column or a group of columns.
Syntax to define a Check constraint:
DEP OF AIML,KNSIT 7
DBMS LABORATORY(BCS403)
DELETE
Commit command
Rollback command
This command restores the database to last commited state. It is also use with savepoint command to
jump to a savepoint in a transaction.
Savepoint command
savepoint command is used to temporarily save a transaction so that you can rollback to that point
whenever necessary.
DEP OF AIML,KNSIT 8
DBMS LABORATORY(BCS403)
LAB EXPERIMENTS
◼ 2. Create the Employee table and insert three records with a rollback.
• CREATE TABLE Employee (
• EMPNO INT,
• ENAME VARCHAR(50),
• JOB VARCHAR(50),
• MANAGER_NO INT,
• SAL DECIMAL(10,2),
• COMMISSION DECIMAL(10,2)
• );
◼ 3. Add primary key constraint and not null constraint to the Employee table.
• ALTER TABLE Employee
• ADD CONSTRAINT PK_Employee PRIMARY KEY (EMPNO),
• MODIFY (ENAME NOT NULL),
• MODIFY (JOB NOT NULL),
• MODIFY (SAL NOT NULL);
◼ 4. Insert null values to the Employee table and verify the result.
• INSERT INTO Employee (EMPNO, ENAME, JOB, MANAGER_NO, SAL, COMMISSION) VALUES
• (4, NULL, 'Manager', 1, 55000.00, NULL);
DEP OF AIML,KNSIT 9
DBMS LABORATORY(BCS403)
2. Create a table called Employee that contain attributes EMPNO,ENAME,JOB, MGR,SAL & execute the
following.
1. Add a column commission with domain to the Employee table.
2. Insert any five records into the table.
3. Update the column details of job
4. Rename the column of Employ table using alter command.
5. Delete the employee whose Empno is 105.
DEP OF AIML,KNSIT 10
DBMS LABORATORY(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)
• IF DELETING THEN
• old_salary := NVL(:OLD.SALARY, 0);
• DBMS_OUTPUT.PUT_LINE('Deleted employee ' || :OLD.ID || ' with salary ' || old_salary);
• END IF;
• END;
DEP OF AIML,KNSIT 11
DBMS LABORATORY(BCS403)
• /
5. Create cursor for Employee table & extract the values from the table. Declare the variables ,Open the
cursor & extrct the values from the cursor. Close the cursor. Employee(E_id, E_name, Age, Salary)
• DECLARE
◼ //Declare variables to store values from the cursor
• v_E_id Employee.E_id%TYPE;
• v_E_name Employee.E_name%TYPE;
• v_Age Employee.Age%TYPE;
• v_Salary Employee.Salary%TYPE;
• BEGIN
◼ Open the cursor
• OPEN emp_cursor;
◼ Process the fetched values (you can perform any operations here)
• DBMS_OUTPUT.PUT_LINE('Employee ID: ' || v_E_id || ', Name: ' || v_E_name || ', Age: ' || v_Age || ', Salary: ' ||
v_Salary);
• END LOOP;
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.
• DECLARE
◼ Declare variables to hold values from the cursor
• v_N_RollCall_id N_RollCall.id%TYPE;
• v_N_RollCall_data N_RollCall.data%TYPE;
DEP OF AIML,KNSIT 12
DBMS LABORATORY(BCS403)
• BEGIN
◼ Open the cursor
• OPEN n_cursor;
7. Install an Open Source NoSQL Data base MangoDB & perform basic CRUD(Create, Read, Update &
Delete) operations. Execute MangoDB basic Queries using CRUD operations.
1. Download MongoDB: Visit the MongoDB download page and select the appropriate version for your operating system.
2. Install MongoDB: Follow the installation instructions provided for your operating system.
1. After installation, start the MongoDB server. The method depends on your operating system.
For example, on Linux/Mac, you can start MongoDB with the following command in your terminal:
sudo service mongod start
1. Open a terminal or command prompt and connect to the MongoDB server using the mongo shell:
mongo
Create Operation
To create a new document in a collection:
DEP OF AIML,KNSIT 13
DBMS LABORATORY(BCS403)
use testDB;
Read Operation
To read documents from a collection:
db.users.find();
Update Operation
To update a document:
Delete Operation
To delete a document:
db.users.find();
db.users.count();
// Sort documents
db.users.find().sort({age: -1});
db.users.find().limit(2);
DEP OF AIML,KNSIT 14