Assignment 3
Assignment 3
Objective: This assignment will help the students exercising more SQL queries, and exercise
relational algebra notations.
Question 1:
Answer each of the following questions briefly. The questions are based on the following
relational schema:
1. Give an example of a foreign key constraint that involves the Dept relation. What are the
options for enforcing this constraint when a user attempts to delete a Dept tuple?
2. Write the SQL statements required to create the preceding relations, including appropri-
ate versions of all primary and foreign key integrity constraints.
3. Define the Dept relation in SQL so that every department is guaranteed to have manager.
4. Write an SQL statement to add John Doe as an employee with eid = 101, age = 2 and salary
= 15,000.
5. Write an SQL statement to give every employee a 10 percent raise.
6. Write an SQL statement to delete the Toy department. Given the referential integrity con-
straints you chose for this schema, explain what happens when this statement is executed
Question 2:
Consider the following SQL query whose answer is shown in the following instance of Student
table:
1. Modify this query so that only the “login name” column is included in the answer
2. If the clause WHERE S.GPA >= 2 is added to the original query, what is the set of tuples
in the answer?
Question 3:
Using Figure 3.7 for the Company database schema, write the relational algebra for the follow-
ing:
1. Retrieve all employees who either work in department 3 and make over $45,000 per year,
or work in department 6 and make over $50,000.
2. Make a list of project numbers for projects that involve an employee whose last name is
‘Smith’, either as a worker or as a manager of the department that controls the project.
3. Retrieve the names of all employees in department 3 who work more than 15 hours per
week on the “ProductY” project.
4. List the names of all employees who have a dependent with the same first name as them-
selves.
Instructions:
You may work in groups of maximum three. In such case, Submission of one member in
the group is sufficient but you have to specify your partner name.
Submission is done ONLY through portal as a softcopy. No submission through emails or
hardcopies will be accepted!
No delay in the submission will be accepted!
You will be notified about your grades once the correction is finished.
Check the deadline on MyGUST.
-2-