Sheet3 Ans
Sheet3 Ans
Faculty of Engineering
Department of Electronics, Communication, and Computer Engineering
Database system
Sheet #3
1- Specify the following queries on the database schema shown in Figure 1, using the relational
operators discussed in this chapter. Also show the result of each query as it would apply to the
database of Figure 2.
a. Retrieve the names of all employees in department 5 who work more than 10 hours per week on the
‘ProductX’ project.
John …, Joyce English
b. List the names of all employees who have a dependent with the same first name as themselves.
null
c. Retrieve the name and address of all employees who work for the ‘Research’ department.
John, Franklin, Rameah, Joyce
d. For every project located in ‘Stafford’, list the project number, the controlling department number, and
the department manager’s last name, address, and birthdate.
10, 4,
30, 4, Wallace, 291 beny…, 1941-6-30
Figure 1
Figure 2
2- Consider the following six relations for an order processing database application in a company:
Here, Ord_Amt refers to total dollar amount of an order; Odate is the date the order was placed; Ship_date
is the date an order is shipped from the warehouse. Assume that an order can be shipped from several
warehouses. Specify the foreign keys for the above schema, stating any assumptions you make. Then
specify the following queries in relational algebra:
a. List the Order# and Ship_date for all orders shipped from Warehouse number ‘W2’.
b. List the Warehouse information from which the Customer named ‘Jose Lopez’ was supplied his orders.
Produce a listing: Order#, Warehouse#.
c. list customer names who were supplied orders of amount greater than 1000$ at 31/12/2008.
3- Consider the following relations for a database that keeps track of business trips of salespersons in
a sales office:
Specify the foreign keys for the above schema, stating any assumptions you make. Then specify the
following queries in relational algebra:
a. Give the details (all attributes of TRIP relation) for trips that exceeded $2000 in expenses.
b. Print the SSN of salesman who took trips to ‘Honolulu’.
4- Suppose that each of the following update operations is applied directly to the database of
Figure 2. Discuss all integrity constraints violated by each operation, if any.
a. Insert <‘Robert’, ‘F’, ‘Scott’, ‘943775543’, ‘1952-06-21’, ‘2365 Newcastle Rd, Bellaire, TX’, M, 58000,
‘888665555’, 1> into EMPLOYEE. correct
b. Insert <‘ProductA’, 4, ‘Bellaire’, 2> into PROJECT. Referential integrity const.
c. Insert <‘Production’, 4, ‘943775543’, ‘1998-10-01’> into DEPARTMENT. Uniqueness const
d. Insert <‘677678989’, null, ‘40.0’> into WORKS_ON. Referential integrity const, entity integrity const
e. Insert <‘453453453’, ‘John’, M, ‘1970-12-12’, ‘SPOUSE’> into DEPENDENT. correct
f. Delete the WORKS_ON tuples with ESSN = ‘333445555’. correct
g. Delete the EMPLOYEE tuple with SSN = ‘987654321’. Referential integrity const
h. Delete the PROJECT tuple with PNAME = ‘ProductX’. Referential integrity const
i. Modify the MGRSSN and MGRSTARTDATE of the DEPARTMENT tuple with DNUMBER = 5 to ‘123456789’ and
‘1999-10-01’, respectively. correct
j. Modify the SUPERSSN attribute of the EMPLOYEE tuple with SSN = ‘999887777’ to ‘943775543’.
Referential integrity const
k. Modify the HOURS attribute of the WORKS_ON tuple with ESSN = ‘999887777’ and PNO = 10 to
‘5.0’. correct