Database Lab Manual Solution: Name
Database Lab Manual Solution: Name
Manual
Solution
Reg No :149
Section: C
Exercise 1.1
Exercise 2.1
a)
1. Each student must be advised by exactly one Professor. However, each
Professor must be advised by one or more Students.
2. Each Professor must teach at least one Class. However, each class must
be taught by exactly one Professor.
b)
1. Each Sales rep must be written one or more Invoice. However, each
Invoice must be written by exactly one Sales rep.
Exercise 5.1
);
CREATE TABLE Employee
Date_of_joining date,
D_O_B date ,
);
Output:
Exercise 6.1
Exercise 7.1
Output:
Q2: select max(salary)as salary, DID from Employee group by DID
Output
Exercise 7.2
Output
Q2: select min(salary) from Employee where salary<>(select min(salary) from Employee)
Output
Q3: select Fname from Employee where salary>(select avg(salary) from employee)
Output
Q4: select Fname from Employee where salary=(select max(salary) from employee)
Output
Q5: select fname,Lname from employee where salary>(select min(salary) from Employee
where DID=11)
Output
Exercise 8.1
Already solved in the lab manual.
Exercise 9.1
Q1:
⚫ Books
⚫ Authors
⚫ Staff
⚫ Members
⚫ Shelves
⚫ Block
Q2:
Q3:
1. Each track must contain exactly one book. However, each book must have exactly one
track.
2. Each book may have at least one author. However, each author may have one or more
books.
3. Each book must be issued to at least one member. However, each member may issue one
or more books.
4. Each member must be an issue by exactly one staff. However, each staff may issue at least
one member.
Q:4
book_data books
book_id b_ID
author_ID Book_name
author
author_ID
author_name
book_issue
staff_ID member
mem_ID m_ID
book_ID m_name
issue_date mem_date
due_date contact_no
retrn_date
staff
staff_ID
staff_name
Exercise 10.1
Q:4
Q:2
2
Q:3
Output
Q:4
Output
:
Exercise 11.1
Question 1:
Output
Output
Question 2:
where(dep.Name='Sales')
Output
Query to update data through the view
Output
Exercise 12.1
Question 1:
as
begin
end
get_grades 'ali'
Output
Question 2:
as
begin
end
Output
as
begin
End
Output
Question 3:
as
begin
End
Output
Question 4:
as
begin
if @avg=@cgpa
else if @cgpa>@avg
else
end
get_info 174
Output