1 a. Explain the entity integrity and referential integrity constraints. Why is each considered important. Give examples.
b. Discuss equijoin and natural join with suitable examples using relational algebra notation.
c. Given the schema:
Passenger (pid,pname,pgender,pcity)
Agency (aid,aname,acity)
Flight (fid,fdate,time src,dest)
Booking (pid,aid,fid,fdate)
Give relation algebra expression for the following:
- Get the complete details of all flights to new Delhi
- Find only the flight numbers for the passenger with paid 123 for flights to Chennai before 06/11/2020
- Find the passenger names for those who do not have any bookings in any flights
- Get the details of flights that are scheduled on both dates 01/12/2020 and 02/12/2020 at 16:00 hours
- Find the details of all the male passengers who are associated with jet agency.
2 a. Explain the ER to relational mapping algorithm with suitable examples for each step.
b. Write SQL query for the following database scheme:
Employee (employee_name,street,city)
Works (employee_name,company_name,salary)
Company (company_name,city)
Manages(employee_name,manager_name)
- Find the name, street address and cities of residence for all employee who work for ‘First Bank Corporation’ and earn more than $10000
- Find the names of all employees in the database who do not work for ‘First Bank Corporation’. Assume that all people work for exactly one company.
- Find the names of all employees in the database who earn more that every employee of ‘First Bank Corporation’. Assume that all people work for at most one company.
- Find the name of the company that has the smallest payroll
- Find the names of all the employee in the database who live on the same cities and on the same streets as do their managers.
3 a. Discuss the characteristics of relation that make them different from ordinary tables.
b. Discuss DIVISION operation. Find the quotient for the following : A/B1,A/B2,A/B3 where A,B1,B2,B3 are
4 a. Explain the steps to convert the basic ER model to relational database schema.
b. For the following relations for a book club:
MEMBERS (member_id,name,desg,age)
BOOKS (book_id,book_title,book_author,book_publisher,book_price)
RESERVES (member_id,book_id,date)
Write the SQL queries
- Find the names of members who are professors older than 45.
- List the titles of books reserved by professors.
- Find ID’s of members who have not reserved books that cost more than Rs.500
- Find the authors and titles of books reserved on 27-may-2017
- Find the names of members who have reserved all books
5 a. Consider the following schema and write the relational algebra :
Sailors (sid,sname,rating,age)
Boats (bid,bname,color)
Reserve (sid,bid,day)
- Retrieve the sailors name who have reserved red and green boats
- Retrieve the sailors name with age over 20 years and reserved black boats
- Retrieve the sailors name who have reserved green boat on Monday
- Retrieve the number of boats which are not reserved
- Retrieve the sailors name who is the oldest sailor with rating 10
b. List Set theory operations used in relational data model. Explain any two with an example.
c. Define the following
a) Relation state b) Domain c) Relation schema d) Arity
6 a. Discuss the various types of JOIN operations with an example. Why is THETA join required?
b. Describe the steps of an algorithm for ER-to-Relational mapping.
c. Describe any two characteristics of relations with suitable example for each.
7. Define the following terms i) Key ii) Super key iii) Candidate key iv) Primary key v) Foreign key
8. Consider the following COMPANY database
EMP(Name,SSN,Salary,SuperSSN,Gender,Dno)
DEPT(DNum,Dname,MgrSSN,Dno)
DEPT_LOC(Dnum,Dlocation)
DEPENDENT(ESSN,Dep_name,Sex)
WORKS_ON(ESSN,Pno,Hours)
PROJECT(Pname,Pnumber,Plocation,Dnum)
Write the relational algebra queries for the following
(i)Retrieve the name, address, salary of employees who work for the Research department.
(ii) find the names of employees who work on all projects controlled by department number4.
iii) Retrieve the SSN of all employees who either in department no :4 or directly supervise an employee who work in department number :4
(iv) Retrieve the names of employees who have no dependents
(v) Retrieve each department number, the number of employees in the department and their average salary.
9. Summarize the steps involved in converting the ER constructs to corresponding relational tables
10. Explain with example basic constraints that can be specified when a database table is created.
11. Write SQL syntax for the following with example: (i) SELECT (ii) ALTER (iii) UPDATE
12.Consider the following relation schema
Works(Pname,Cname,salary)
Lives(Pname,Street,City)
located_in (Cname, city)
Manager(Pname,Mgrname)
Write the SQL queries for the following
i) Find the names of all persons who live in the city Bangalore.
ii) Retrieve the names of all person of "Infosys" whose salary is between Rs .50000
iii) Find the names of all persons who lives and work in the same city
iv) List the names of the people who work for “Tech M” along with the cities they live in.
v) Find the average salary of “Infosys” persons