0% found this document useful (0 votes)
24 views2 pages

(I) Define The Tables. Identify The Keys and Foreign Keys

The document contains 4 sections that define tables and relationships and provide SQL queries to retrieve information from the tables: 1) The first section defines tables for physicians, patients, and visits and provides sample queries to retrieve information and counts. 2) The second section defines tables for customers, items, and orders and provides queries to list customers by item properties and display customer and order details. 3) The third section defines tables for employees, departments, and dependents and provides queries to filter employees by department and location and update salaries and locations. 4) The fourth section defines tables for employee names, locations, companies, and managers and provides queries to filter results by manager and location.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
24 views2 pages

(I) Define The Tables. Identify The Keys and Foreign Keys

The document contains 4 sections that define tables and relationships and provide SQL queries to retrieve information from the tables: 1) The first section defines tables for physicians, patients, and visits and provides sample queries to retrieve information and counts. 2) The second section defines tables for customers, items, and orders and provides queries to list customers by item properties and display customer and order details. 3) The third section defines tables for employees, departments, and dependents and provides queries to filter employees by department and location and update salaries and locations. 4) The fourth section defines tables for employee names, locations, companies, and managers and provides queries to filter results by manager and location.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 2

1.

Consider the following relations Physician (rgno, phyname, addr, phno) Patient (ptname, ptaddr) Visits (rgno, ptname, dateofvisit, fees-charged) Answer the following in SQL : (i) Define the tables. Identify the keys and foreign keys. (ii) List the physician information with their regno and name. (iii) List the patient name and address with the visiting date. (iv) How many patients are there? (v) Display the patient information with the physician information. 2. Consider the following relations with key underlined Customer (C#, Cname, Address) Item (I#, Iname, Price, Weight) Order (O#, C#, I#, Quantity) Write SQL queries for the following: a. List the names of customers who have ordered items weighing more than 1000 b. List the names of customers who have ordered items priced over Rs.500. c. display the customer information with the ordering details. d. list the items which ordered less than 500 units. 3. Consider the following relations Employee (E#, Ename, salary, Bdate, D#) Department (D#, Dname, mgremp#, Location) Dependent (E#, DependentName) Write SQL queries for the following: i. List the names of employees working for research department. ii. List all the employees who earn more than the average salary of all employees. iii. Increase the salary of managers by 10%. iv. List the names of all employees working in Delhi. v. Change the location of all departments to Mumbai which have location as Bombay 4. Consider the following relations with key underlined lives (person_name, street, city) works (person_name, company_name, salary) located (company_name, city) manages (person_name, manager_name) Answer the following using SQL:

(i) Find the names and city of persons who work for manager John. (ii) Find the names of persons who live in the same city as the company they work for. (iii) Johns manager has changed. The new manager is Anna. (iv) Susan doesnt work anymore.

You might also like