CPSC 304 Database Management Systems ... - Ugrad.cs.ubc.ca
CPSC 304 Database Management Systems ... - Ugrad.cs.ubc.ca
CPSC 304 Database Management Systems ... - Ugrad.cs.ubc.ca
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Problem 5: (Exercise 19.7 of the book) Suppose you are given a relation R with<br />
four attributes ABCD. For each of the following sets of FDs, assuming those are<br />
the only dependencies that hold for R, do the following:<br />
(a) Identify the <strong>ca</strong>ndidate key(s) for R.<br />
(b) Identify the best normal form that R satisfies (3NF, BCNF, or none).<br />
(c) If R is not in BCNF, decompose it into a set of BCNF relations that<br />
preserve the dependencies.<br />
1. C → D, C → A, B → C<br />
2. B → C, D → A<br />
3. ABC → D, D → A<br />
4. A → B, BC → D, A → C<br />
5. AB → C, AB → D, C → A, D → B<br />
RA, DRC and SQL<br />
Problem 6: Consider the following schemas:<br />
Branch (bname, assets, bcity)<br />
Customer (cname, street, ccity)<br />
Deposit (bname, account#, cname, balance)<br />
Borrow (bname, loan#, cname, amount)<br />
Rewrite the English queries below using:<br />
(a) Relational algebra<br />
(b) SQL<br />
1. Find all customers having a loan at the bank and the cities in which they live.<br />
2. Find the largest account balance in the bank.<br />
3. Find all the customers who have an account at all branches lo<strong>ca</strong>ted in<br />
Vancouver.<br />
Problem 7: Using the same schemas as in Problem 6, tell what the English<br />
meanings of the following DRC queries are.<br />
1. { < b , l,<br />
c,<br />
a > | < b,<br />
l,<br />
c,<br />
a >∈borrow<br />
∧ a > 1200}<br />
2. { < c > | ∃b,<br />
l,<br />
a(<br />
< b,<br />
l,<br />
c,<br />
a >∈ borrow ∧ a > 1200)}<br />
3. { < c > | ∀x,<br />
y,<br />
z(<br />
¬ ( < x,<br />
y,<br />
z >∈ branch)<br />
∨ z ≠"<br />
Vancouver"<br />
∨(<br />
∃a,<br />
n(<br />
< x,<br />
a,<br />
c,<br />
n >∈ deposit)))}<br />
ER Diagrams and Relational Schema<br />
Problem 8: Consider that the officials in YVR have decided to organize all the<br />
information related to the airport in a DBMS and you have been hired to design<br />
the database. Your first task is to organize the information about the planes<br />
stationed and maintained at the airport. The relevant information is as follows:<br />
2