DBMS Lab Manual R-19
DBMS Lab Manual R-19
LAB MANUAL
(CSL 402)
DEPARTMENT’S VISION
Impart prime content education to develop technically proficient and socially responsible
engineers in the emerging branches of AI.
DEPARTMENT’S MISSION
1. To provide students with a comprehensive education to prepare them for the rigors in the
domain of AI
3. To encourage the capacity for lifelong learning necessary for career advancement.
4. To help build relationships with alumni and industry for the betterment of students' overall
growth.
⚫ PEO3: Promote services in the field of Artificial Intelligence Engineering through excellent
technical and communication skills.
⚫ PSO1: Students are exposed to cutting-edge trends and technology to prepare them for
challenging work in the industry, higher education, and professional careers.
⚫ PSO2: Practice skills learnt in the field of Artificial Intelligence, Data Mining. Machine
Learning, Cloud Computing, Optimization, Networking and Security, Deep Learning to
different domains such as Healthcare, Education, Agriculture, Finance, Social Media etc.
LO1: Design and draw ER and EER diagram for the real life problem with software tool.
LO2: Create and update database and tables with different DDL and DML statements.
LO3: Apply /add integrity constraints and able to provide security to data.
LO4: Implement and execute complex queries.
LO5: Apply triggers and procedures for specific module/task
PS PS
Course Outcomes (COs) / Program Outcomes (POs) 1 2 3 4 5 6 7 8 9 10 11 12 O1 O2
3: Well prepared and puts 2: Not prepared but puts 1: Neither prepared nor puts
efforts. efforts or prepared but doesn't efforts
put efforts
3: Uses all perfect Instructions 2: Uses some perfect 1: Doesn't use any of the
/ Interrupts/Presented well. Instructions / Interrupts/ proper Instruction / Interrupt/
moderate presentation. Not presented properly.
3: Participate and gets proper 2: Participate but doesn't get 1: Neither Participate nor gets
results proper result or gets result but the results
with the help of faculty in-
charge
4. Punctuality
3: Get the experiment 2: Some time delays the 1: Most of the time delays
checked in-time and is always experiment checking or is late experiment checking and / or
in-time to the lab sessions to the lab sessions for few comes late for lab sessions
times
5. Lab Ethics
3: Follows proper lab ethics 2: Sometimes doesn't follow 1: Most of the times makes
by keeping the lab clean and
placing things at their right the lab ethics the lab untidy and keeps
place things at wrong place
5. Lab Ethics
Total
Average
Faculty In-charge
Aim: Identify the case study of the problem and design ER model.
Justification:
Each team has multiple players and each player has to belong to at least one team,
so the cardinality from players to team is many to one. Players are given position
as primary key and a multi valued attribute called injury record. Each team has a
captain who is also the player. And since 1 team can have only 1 captain the
cardinality is one to one. A game is played between two teams, guest and host team
Justification:
Each patient can have their patient id as primary key. Amongst other attributes,
address is a composite attribute. A patient is treated by only one doctor and one
doctor can treat multiple patients, so the cardinality from patient to doctor is many
to one. Since a patient will be treated and a doctor will treat someone, its total
participation from both ends. A doctor has multiple attributes out of which the
doctor’s id is a primary key and their qualifications are multivalued here. A patient
may or may not have to go through some tests so its partial participation from
patient’s side but total participation from tests end. A patient maybe told to take
Conclusion:
Relational mapping:
5. List all employees and their job who are in department number 20.
8. Display the name of all employees whose commission is greater than salary.
9. Display name and job of employees whose salary is greater than 2000.
10.Give list of all employee names along with their monthly and annual salary.
11. Display names and number of employees working in department number 10.
12. Give the detailed list of all the dept and deptno but change the column name as
DEPARTMENT and DEPARTMENT NUMBER.
13. List all the managers with their respective names, manager employee number
and dept no.
15. Display list of all employees whose job is analyst and salary is greater than 1000.
16. Find details of all managers who are not in department number 10.
17. Compute details of those employees who are neither Clerk nor Salesman nor
Analyst.
18. Display name, salary and job of all employees ordered by their JOB.
19. List name, salary, job of all employees which are in descending order of their
SALARY and ascending order of their JOB.
20. Compute details of all employees in ascending order of JOB and descending
order by NAME.
Conclusion:
20. Compute details of all employees in ascending order of JOB and descending
order by NAME.
Conclusion:
5. List all employee names with blank left and right padding.
6. List all employee names with character left and right padding.
7. Right trim all the employees names ending with N.
8. List the names of all department names.
9. List the first 3 characters of all employee names.
10. Find the location number of character 'A' in department name.
Date Formats
Date functions
Implement Following date functions:
1. Round(date,[precision])
2. trunc(date,[precision])
3. Add_months(date,number)
4. Last_day(date)
5. Next_day(day,daytime)
6. Months_between(date1,date2)
Conclusion:
Conclusion:
Aggregate Functions:
Group By Clause:
The GROUP BY statement is often used with aggregate functions to group the
result set by one or more columns.
Having Clause:
The WHERE clause filters the rows from the result set based on the columns
specified in the WHERE clause condition, whereas the HAVING clause filters
the groups created by the GROUP BYclause from the result set based on the
conditions specified in the HAVING clause. HAVING clause is executed after
the GROUP BY clause.
18. Get the department no which has more than one clerk working under
it.
19. For each job Get the average salary which is greater than average
salary of all managers.
20. Get the number of job positions in each department.
21. Get the number of job positions in each department only if there are
at least 2 employees on that position.
Conclusion:
8. Get employee nos. who work on at least one project that employee
107 works on.
Consider Emp(empno,ename,sal,comm,mgr,deptno,job,hiredate)
Conclusion:
1. Write a function to display dept name and location by inputting dept no.
Consider schema dept(deptno,dname,loc).
2. Write a function to calculate gross salary of an employee. Consider schema
Emp(empno,ename,sal,comm,deptno,hiredate,job) and insert the empno and gross
salary in Gross_emp table.
3. Write a function to concate and convert a text into upper or lower case by
checking the flag value. If flag is true the concate and convert the text into
uppercase otherwise in lowercase. A function accepts 3 arguments. Twp arguments
of type text and one is 27ibonac with default value false and returns a text value.
Sample Example:
1. Concating
create or replace function concat_lower_or_upper(a text, b text, uppercase
boolean default false)
returns text
as
$$
declare mytext text;
begin
if ($3 = true) then select into mytext upper($1 || ' ' || $2);
else
select into mytext lower($1 || ' ' || $2);
end if;
return mytext;
end;
$$
language 'plpgsql'
select concat_lower_or_upper('Hello','world',true);
select concat_lower_or_upper('Hello','world',false);
select concat_lower_or_upper('Hello','world');
Conclusion:
Conclusion: