This document contains review problems for a Database Management Systems exam. It includes questions on relational operators, query optimization, true/false statements, creating and modifying tables and views. The questions cover topics like join orders, indexes, clustered vs unclustered indexes, and query performance.
This document contains review problems for a Database Management Systems exam. It includes questions on relational operators, query optimization, true/false statements, creating and modifying tables and views. The questions cover topics like join orders, indexes, clustered vs unclustered indexes, and query performance.
This document contains review problems for a Database Management Systems exam. It includes questions on relational operators, query optimization, true/false statements, creating and modifying tables and views. The questions cover topics like join orders, indexes, clustered vs unclustered indexes, and query performance.
Question 1 Relational Operators a)3 b)1 c)1 d)5 e)1 f)10 g)3,6 h)5,6 Question 2 Relational Query Optimization 1. Number of pages and tuples in each relation. Number of distinct values in Supply.sid, Supply.pid, Supplies.city and Part.price. High and low values in Part.price. 2. (SU)P, (US)P, (PU)S, (UP)S 3. On S.sid, U.sid, U.pid, P.pid, S.city, P.price (most likely only a clustered one would be used ). 4. Maintain plans that produce tuples in S.sname, P.pname order even if they are higher cost. Final plan would need to include a sort (or hash) to perform projection. 5. As in (4) plans that produce tuples in S.sname, P.pname order even if they are higher cost. Final plan would need to include a sort (or hash) to perform aggregation. 6. Number of distinct values of P.city (in addition to above). All above join orders and (PS)U and (SP)U. Also index on P.city. Question 3 1)T 2)F 3)T 4)F 5)F 6)T 7)F 8)F 9)T 10)T 11)T 12)F 13)F 14)T Question 4 1. Tables create table Company ( companyId integer, name char(50), address char(50), sector char(20), primary key(companyId), ) create table Price ( companyId integer, date date, value integer, primary key(companyId, date) ) 2. Modications (a) in the company table: sector not null (b) in the company table: unique(name,sector) (c) in the price table: foreign key(companyId) references Company (d) in the price table: check (value =< 1000) 3. Views create view transp(companyId, date,value) as ( select c.companyId, date, value from price p, company c where p.companyId=c.companyId and sector = 'transportation' ) create view high(companyId,date,value) as ( select c.companyId, date, value from price p, company c where p.companyId=c.companyId and sector = 'nance' and value > ( select avg(value) from price p1, company c1 where p1.companyId=c1.companyId and sector = 'nance' and p1.date = p.date ) ) create view sector(sector,date,price) as ( select sector, date, avg(value) from price p, company c where p.companyId=c.companyId group by sector, date )
Question 5 A)T B)F C)F D)T E)F
Question 6 1. Q1. There are many more tuples per page in Writer than in Paper. Hence, for Q1, having a clustered index will make the query about 80 times faster than an unclustered. For Q2, a clustered index is only about twice as fast as an unclustered index. 2. Let h be the height of the B+-tree index. Writer contains 50 pages. So a le scan costs 50 IOs. For an unclusterd index the cost is h + N. If N 50 - h the scan is better, otherwise the index is better.b