168360 Database Systems Semester I/2547 Page 1/1
Total Page:16
File Type:pdf, Size:1020Kb
168360 Database Systems Semester I/2547 Page 1/1
Exercise 3 Given: June 25, 2004, Submitted: June 28, 2004
Maximum number of points possible: 20. This exercise counts for 1% of your overall grade. 1. Define the following terms: relational schema, relational database schema, domain, attribute, attribute domain, relation instance, relation cardinality, and relation degree (8 points)
2. Does the relational model, as seen by an SQL query writer, provide physical and logical data independence? Explain (2 points)
3. What is the difference between a candidate key and the primary key for a given relation? What is a superkey? Consider the instance of Students relation shown below, identify a set of attributes that are considered as “a candidate key” and a set of attributes that are considered as “a superkey” (4 points)
4. Answer each of the following questions briefly. The questions are based on the following relational schema:
Emp(eid: integer, ename: string, age: integer, salary:real) Works(eid:integer, did:integer, pcttime:integer) Dept(did:integer, dname:string, budget:real, managerid:integer)
4.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 attempt to delete a Dept tuple? (1 point)
4.2 Write the SQL statements required to create the preceding relations, including appropriate versions of all primary and foreign key integrity constraints. Note that for a foreign key constraint of relation ‘Works’, we would like to delete all Works tuples that refer to the department or the employee if that department or that employee is deleted. In the ‘Dept’ relation, if an employee who is a manager resigns (deleted), we want to say that we will assign a manager for that department soon but this information is not currently applicable (set the value to null) (1 point)
4.3 Define the Dept relation in SQL so that every department is guaranteed to have a manager (1 point)
4.4 Write an SQL statement to add John Doe as an employee with eid = 101, age = 32 and salary = 15,000 (1 point)
4.5 Write an SQL statement to give every employee a 10 percent raise (1 point)
4.6 Write an SQL statement to delete the Toy department (dname = ‘Toy’). Given the referential integrity constraint in the schema, explain what happens when this statement is executed (1 point)