Sie sind auf Seite 1von 14

Database Systems (COT-313 )

Database Management Systems ( IT-216 )


Lab Practicals
Experiment No.-01
Installation of MYSQL/ ORACLE (Refer Video Tutorial)
http://www.spoken-tutorial.org/
Show Video from link http://www.spoken-tutorial.org/keyword-search/?q=SQL

Experiment No.-02
Focus Area: Create tables and insert tuples
Create tables and insert tuples in the databases described by the following relational database
schema.
a) CAR (Serial-no, Model, Manufacturer, Price)
OPTION (Serial-no, Option-name, Price)
SALE (Salesperson-id, Serial-no, Date, Sale-price)
SALESPERSON (Salesperson-id, Name, Phone)
b) CATALOG (Cno, Ctitle)
STUDENTS (Sid, Fname, Lname, Mname)
COURSES (Term, Sec-no, Cno, A, B, C, D)
ENROLLS (Sid, Term, Sec-no)
c) SUPPLIER (Sno, Sname)
PART (PTno, PTname)
PROJECT (PJno, PJname)
SUPPLY (Sno, PTno, PJno)
d) EMPLOYEE (Employee-name, Street, city)
WORKS (Employee-name, Company-name, Salary)
COMPANY (Company -name, City)
MANAGES (Employee-name, Manager-name)
e) EMPLOYEE (Employee-name, Street, city)
WORKS (Employee-name, Company-name, Salary)
COMPANY (Company -name, City)
MANAGES (Employee-name, Manager-name)

Experiment No.-03
Focus Area: Tables and various Key Constraints
Create a database for the following relational schema and insert tuples.
STUDENT (Roll-No, Name, Gender, Degree, Semester, Contact no, email-id, Guide-No)
GUIDE (Guide-No , Guide-name, Guide-research-area, Email-id)
PROJECT (Project-No, Project-title, Project-area, Project-Year-Month, Guide-No)
GROUP (Group-Code, Roll-No )
PROJECT-GROUP (Group-Code, Project-No, No-of-students)
Write the following SQL queries for the database.
(1). Change data type of the attribute Roll-No of the table Student from Number (10) to
Varchar (10).
(2). Add a constraint Check on attribute Gender of the table Student such that the attribute
will able to accept only (M,F, m,f) values.
(3). Add a constraint on the attribute Degree of the table Student such that no null values
could be inserted in it.
(4). Get a list of guides who are guiding more than two groups of students.
(5). Get a list of Project-No, Project-name, and names of guides who are guiding projects in
the project area "Database".
(6). Update guide details of the student with Roll-no 110011 for new guide as Ram
Mohan & Guide-No 11.
(7). Remove Guide details, guide no is 15 and assign a new guide with Guide-No 10 to
all the students who were earlier assigned to the guide with Guide-No. '15'.

STUDENT

GROUP

GUIDE

PROJECT

Exp
perimentt No.-04
Createe a relationaal database for a Univversity desccribed by thhe following relationall schema
and poopulate it byy tuples.
ROOM (Buuilding, Rooom Number,, capacity)
CLASSR
DEPARTMENT (D
Dept name, building,
b
bu
udget)
i title, deppt name, creedits)
COURSE (Course id,
INSTRU
UCTER (I-ID
D, name, deept name, saalary)
SECTIO
ON (Course id, sec id, semester,
s
yeear, buildingg, room num
mber, time slot id)
TEACH
HES (I-ID, course id, sec id, semestter, year)
STUDEN
NT (S-ID, name,
n
dept name,
n
tot crredit)
TAKES (ID, Course-id, sec-id,, semester, year,
y
grade))
ADVISO
OR (S- ID, I-ID)
I
TIME SL
LOT (Timee-slot-id, dayy, start timee, end time))
PREREQ
Q (Course-iid, Prereq-idd)

Write thhe followingg queries inn the SQL foor the aboveementionedd database of a universiity.
(1). Uppdate, Salaryy of each innstructor, whho is workin
ng in Deparrtment EC.
(2). Uppdate the Rooom no for Course
C
scheeduled on 12.30-01.25 from LHC--204 to LHC
C-102.
(3). Reetrieve the names
n
of all instructors along witth their department nam
mes and department
buiilding namee.

(4). Find the names of all instructors in the Computer Science department who have salary
greater than Rs. 70,000.
(5). For all instructors in the university who have taught some course, find their names and
the course ID of all courses they taught
(6). Find the titles of courses in the Comp. Sc. department that have 3 credits.
(7). Find the course names and their credits running in semester 4.
(8). List the section name, course name whose class are engaged in room no LHC-102.
(9). Find the pairs of Student ID, Supervisor ID where supervisor is teacher and advisor of the
student, also retrieve the name department.
(10). Retrieve the list of Rooms where the entire all the classes are scheduled before 12.00
am.
(11). Retrieve the list of room number & time slot where all classes of Computer Sci.
Semester 7th are scheduled.
(12). Retrieve the Course Name, Course no, Semester, Room no, time slot, taught by Prof
ABC.

Experiment No.-05
Specify the following queries in SQL on the database schema University
(experiment no 04)

(1). Find the names of all departments whose building name includes the substring
Watson.
(2). Find the names of instructors with salary amounts between $90,000 and $100,000.
(3). To list in alphabetic order all instructors in the Physics department.
(4). Retrieve the list of students, who are born on 1990.
(5). Retrieve the list of courses taught by teacher whose name consist R as fourth
word.
(6). Find the IDs of all students who were taught by an instructor namedEinstein
makes sure there are no duplicates in the result.
(7). Find the average salary of instructors in the Computer Science department
(8). Find the total number of course in University
(9). Find the total number of instructors who teach a course in the Spring 2010
semester
(10). Find the average salary in each department
(11). Find all instructors earning the highest salary (there may be more than one with
the same salary).
(12). Find the average salary of all instructors
(13). Find the number of instructors in each department who teach a course in the
Spring 2010 semester.

Experiment No.-06
Specify the following queries in SQL on the database schema University
(experiment no 04)
(1). Find the average salary of instructors in those departments where the average
salary is more than $42,000.
(2). Find the average salary of all instructors.
(3). Find the total number of student enrolled in each of department in university.
(4). Find the total number of student enrolled in each of department in university.
(5). Find the maximum enrolment, across all sections, in Autumn 2009.
(6). For each course section offered in 2009, find the average total credits (tot cred) of
all students enrolled in the section, if the section had at least 2 students.
(7). Find the average instructors salaries of those departments where the average
salary is greater than $42,000
(8). Find the total number of students with each grade.
(9). Find the lowest, across all departments, of the per-department maximum salary
computed by the preceding query.
(10). For each department, find the maximum salary of instructors in that department.
You may assume that every department has at least one instructor.
(11). Find the total number of student enrolled in each of department in university.
(12). Retrieve the total count of student in each department who earned credit more than
8 overall.
(13). Retrieve the name of student from Computer Science & EC who earn total credits
more than 7.
(14). Find the name of classrooms shared by EC dept & Computer Science
deptdaywise.
(15). List the name of Instructor, Course & total no of student in where student more
than 20% students earn 9 credits.
(16). List the name of faculty, dept of faculty, course name who are teaching a subject
of other department.

Experiment No.-07

Specify the following queries in SQL on the database schema University


(experiment no 04)
(1). Retrieve the name department which has amount no of budget; also retrieve the
number of classrooms in dept and capacity of classroom.
(2). List the name computer science faculties, whose classes are slotted after 12.35 pm
in Computer Science dept.
(3). List the name computer science faculties, whose classes are slotted after 12.35 pm
in Computer Science dept and EC dept of 6th and 8th Semester.
(4). Find the IDs and names of all students who have not taken any course offering
before Spring 2009.
(5). Find the names of all students who have taken at least one Comp. Sci. course;
make sure there are no duplicate names in the result.
(6).

Find the names of course on which more than 20 student earned less than credits
5 on 3rd Year.

(7). List the name of instructors who are not teaching any 8th semester course.
(8). List of the all students whose advisor belongs to other department.
(9). Retrieve the name of student, subject name taught by an instructor, who is not an
adviser to any of the students.

Experiment No.-08

Create a relational database schema for a Company, described by the following


relations and Insert tuples.

Employee (F-name, L-name, Emp-id, Bdate, Address, Gender, Salary, Super-Empid, D-no)
Department (D-name, D-no, D-Mgr-id, Mgr-start-date )
Dept-Location(D-no, D-location )
Project (P-name, P-number, P-location, D-no )
Works-on (Emp-id, P-no, Hours )
Dependent (Emp-id, Dependent-name, Gender, Bdate, Relationship)

Sppecify the following


f
quueries in SQ
QL on the daatabase schema Company
(11). Compaany decidedd to give a raiseon sallaries of evvery employyee, workin
ng on the
ProduuctX projecct by 10 perccent.
(22). Find thhe names annd address of
o all employ
yees who work on sam
me departmeent.
(33). Retrievve the namee & employeee no of em
mployees, whhose salary is between
n $30,000
and $40,000.
(44). Find thhe names off all employyees who aree directly suupervised byy Franklin
(55).

List thhe name and


a
addresss of all em
mployees who work for the R
Research
departm
ment.

(6). List the names of employees who works on all project controlled by department
number 5.
(7). List the names of all employees who have a dependent with the same first name as
themselves.
(8).

Retrieve the names of all employees in department 5 who work more than 10
hours per week on XYZ Project.

(9). Retrieve a list of employees and the projects they are working on, ordered by
department and, within each department, ordered alphabetically by last name, then
first name.

Experiment No.-09
Specify the following queries in SQL on the database schema Company
(Experiment no. 08)

(1). Retrieve the employee details, whose first name start with AB.
(2). Retrieve the employee details, whose third character of first name S.
(3). Retrieve all employees, whose address is in Houston, Texas.
(4). Retrieve the employees, whose supervisor city name start name NEW.
(5). Retrieve the project name, whose location pin code consists first 3 digits are
111.
(6). Retrieve the employee name, Employee id, dept no, project no, whose were born
during 1980 and working in a project located at INDIA.
(7). Retrieve the total number of Employees in organization.
(8). Count the number of distinct salary values in the Company.
(9). Retrieve the total number of Supervisor in organization.
(10). Retrieve the total no of Female Employee in organization, whose salary is more
than 25000.
(11). Retrieve the total number projects currently in company.
(12). Find the sum of the salaries of all employees, the maximum salary, the minimum
salary, and the average salary.
(13). Retrieve the average salary of all female employees.
(14). Retrieve the Employee id & no of projects, employee is working on.
(15). Retrieve employee id, employee name, total no of hours he works on project

Experiment No.-10
Specify the following queries in SQL on the database schema Company
(Experiment no. 08)
(1). Retrieve the total no male & female employee in the Organization
(2). Retrieve the total no of employee working, for each of the department
(3). For each department, retrieve the department name and the average salary of all
employees working in that department.
(4). For each project, retrieve the project number, the project name and the number of
employees who work on that project
(5). For each project, list the project name and total no of hours per week (by all
employees) spent on the project.
(6). Retrieve the Project name & no of employee,inwhich least number of employees
are working.
(7). Retrieve the name of department name & department No, number of projects, who
are controlling highest no of projects.
(8).

For each project on which more than two employees work, retrieve the project
number, the project name, and the number of employees who work on the project.

(9). For each project, retrieve the project number, the project name, and the number of
employees from department 1 who work on the project.
(10). For each department that has more than five employees, retrieve the department
number and the number of its employees who are making more than $40,000.
(11). Retrieve the names of the employee who do not have supervisors.
(12). Retrieve the names of employees who work on all projects controlled by
department No 05.
(13). Find the names of all employees who earn more than average salary of company.
(14). Make a list of project numbers for projects that involve an employee whose last
name is Smith, either as a worker or as a manager of the department that controls
the project.

Experiment No.-11

Specify the following queries in SQL on the database schema Company


(Experiment no. 08)

(1). Retrieve the names of all employees who work on every project.
(2). List the last name of all department managers who have no dependent.
(3). List the names of managers who have at least one dependent.
(4). Retrieve the names of employees who do not work on any project
(5). Retrieve the names of employees who work on all projects.
(6). Retrieve the name of department name & department No, number of employees,
Number of projects, who is controlling highest no of projects.
(7). List the name of each employee who works on some project controlled by
department number 5.
(8). Retrieve the name of department name & department No, number of employees,
Number of projects, who is controlling highest no of projects.
(9).

A view that has the department name, manager name and manager salary for
every department.

(10). A view that has the project name, controlling department, number of employees,
and total hours worked per week for each project.
(11). A view that has the project name, controlling department name, number of
employees, total hours per week on the project for each project with more than
one employee working on it.

Assignment DB Design

A database is being constructed to keep track of the teams and games of asports league.
A team has a number of players, not all of whom participate ineach game. It is desired
to keep track of the players participating in eachgame for each team, the positions they
played in that game, and the result ofthe game. Design an ER schema diagram for this
application, stating anyassumptions you make. Choose your favourite sport (e.g., soccer,
baseball,football).

(1). Find the name of Team, who won the maximum number of matches /games.
(2). Retrieve the name of players of each participating team, who played highest
number of games (for a team).
(3). Retrieve the name of players of each team, who played on every match in which
the team is winning team.
(4). Retrieve the name of venues in which each team won at least a game/match.
(5). Find the name of players for each team in tournament that played at least in three
different positions on different games/matches for each team.
(6). Retrieve the Team Name, Player Name, opponent team, player position for all
matches where team is losing side.

Das könnte Ihnen auch gefallen