Course Code: CSE-3106 Course Title: Database Management System Lab Set-A 1. Patient(ID, FirstName, SurName, Admission_Date, Dr_ID,Ward_No) Ailment(Ailment_ID, Name,Patient_ID) Ward(Ward_No, Ward_Name) Doctor(ID,SurName,First_Name,No_of_Patient, Ailment_ID) For the schema above, Write SQL to implement the following queries: i. List the surnames of all patient of ‘Dr.Jones’. ii. List all the doctors who specialize in the ailment suffered by the patient whose surname is 'Thomas'. iii. List the ward number and ward name of the wards which have the most patients. iv. Provide a list of all patients who have not suffered any ailment. v. Show the Doctor's name who have the third highest no of patient. 2. The registrar office of Mawlana Bhashani Science & Technology University would like to maintain data about the following entities i. Courses including number, title, credit, syllabus and prerequisites ii. Course offering including course number, year, semester, instructor, Timings and class room. iii. Students including identification number, name, department and designation Registrar office seeks help from the students of CSE department. Your job is to construct an E-R diagram for the registrar office. Write down all the assumptions that you make about the mapping constraints. 3. You are given a table name population. Which includes NID, Name, Date of Birth. You are also given two table dead_people and Birth_people. Your task is create a tigger that will automatically fire when any child born (Birth_people table) it will automatically fire and update the value in population table. Similarly when any people die (Birth_people table) it will automatically fire and decrease the value in population table. Set-B 1. Consider the following employee Database where primary keys are underlined: employee(employee-name, street, city) works(employee-name, company-name, salary) company(company-name, city) manages(employee-name, manager-name) Now construct the following SQL queries for this relational database i. Find the names, street & company name of all employee who lives in Dhaka city. ii. Find the names of all employee with salary who live in rajshahi & salary greater than 10,000/iii. Find the names of all employees who earn more than every employee of sonali bank ltd. iv. Find the names of all company with average salary whose average salary is less than 15,000/2. Design a database for an airline. The database must keep track of customers and their reservations, flights and their status, seat assignments on individual flights, and the schedule and routing of future flights. Your design should include an E-R diagram, a set of relational schemas, and a list of constraints, including primary-key and foreign-key constraints. 3. Create a Trigger that raises an User Defined Error Message and does not allow updating and Insertion Set: C 1. Consider the following Banking Database Bank where primary keys are underlined. branch(branch-name, branch-city, assets) customer(customer-name, customer-street, customer-city) loan(loan-number, branch-name, amount) borrower(customer-name, loan-number) account(account-number, branch-name, balance) depositor(customer-name, account-number) Give an expression in the relational algebra to express each of the following queries: i. Find the names of all customers who have a loan, an account, or both, from the bank. ii. Find the names of all customers who have a loan at the Perryridge branch. iii. Find the names of all employees who live in the same city and on the same street as do their managers. iv. Find the loan number for each loan of an amount greater than 12,000/2. Construct an E-R diagram for car-insurance company whose customers own one or more cars each. Each car has associated with it zero to any number of recorded accidents. Where i. Person: include drive-id, address and name. ii. Car: include license, model year. iii. Accident: include report-number, location, and date. 3. Suppose you are given a table (student) of 10 columns. Your tasks is to create a trigger that will fire when you insert value to student and stored the similar column value to another three table which columns are combination of student table. Set: D 1. Construct an ER diagram for a hospital with a set of patients and a set of medical doctors. Associate With each patient and examinations conducted. 2. The following tables form part of a database held in a relational DBMS:(6) Employee (empno, name, office, age) Books (isbn, title, authors, publisher) Loan (empno, isbn, date) Write the following queries in Relational Algebra a. Find the name of all employees who have borrowed a book published by McGraw-Hill. b. Find the name of all employees who have borrowed all book published by McGraw-Hill. c. Find the names of employees who have borrowed more than five different books published by McGraw-Hill. d. For each publisher, find the name of employees who have borrowed more than five books of that publisher 3. Table:Department Department _ID(PK) Table:Employee Employee_ID(PK) Department _Name Employee_Name Employee_Age Table:Employee_Department Employee_ID(PK) Department_ID(PK) FK:Employee_ID references Employee(Employee_ID),Department_ID references Department(Dept_ID) Table:Salary Salary _Scale(PK) Salary _Amount Table: Employee_ Salary Employee_ID(PK) Salary _Scale(PK) FK: Employee_ID references Employee (Building _ID), Salary _Scale references Salary (Salary _ Salary) i. ii. iii. Find the Department names where the employee’s average salary is more than 10000. Find the employee names who has paid in salary scale 1. Update the employee ages by increasing 10 years whose ages are not equal to average age.