Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Classroom Exercise: SQL u Consider a bookstore database with this schema: w Books(bookid, title, author, year) w Customers (customerid, name, email)

Similar presentations


Presentation on theme: "1 Classroom Exercise: SQL u Consider a bookstore database with this schema: w Books(bookid, title, author, year) w Customers (customerid, name, email)"— Presentation transcript:

1 1 Classroom Exercise: SQL u Consider a bookstore database with this schema: w Books(bookid, title, author, year) w Customers (customerid, name, ) w Purchases (customerid, bookid, year) w Reviews (customerid, bookid, rating) // rating is 1, 2, 3, … w Pricing (bookid, format, price) // format is 'audio', 'hb', 'pb',… u Write SQL queries to find the following information: 1. titles of all books written by 'EDMUND MORGAN' since titles, authors and prices of all books with 'CIVIL WAR' in the title available in audio 3. list how many books 'JOHN SMITH' bought in each year that he bought at least one book 4. names and addresses of all customers who bought more than one book in titles, authors, and average ratings for all books with 'CIVIL WAR' in the title

2 2 Normalization Example uConsider relation R(name, SSN, BD, childName, childSSN, childBD, VIN, make) uAssume these FDs: wSSN -> name BD wchildSSN -> childName childBD wVIN -> make uTherefore key is {SSN,childSSN,VIN} and all FDs violate BCNF. uAssume these MVDs: wSSN ->-> childSSN childName childBD wSSN ->-> VIN make uThus all MVDs violate 4NF.

3 3 Normalization Ex. cont'd uDecompose R using SSN ->-> childSSN childName childBD: wR1(SSN,childSSN,childName,childBD) wR2(SSN,name,BD,VIN,make) uDecompose R2 using SSN ->-> VIN make: wR2.1(SSN,VIN,make) wR2.2(SSN,name,BD) uDecompose R1 using childSSN -> childName childBD: wR1.1(childSSN,childName,childBD) wR1.2(SSN,childSSN) uDecompose R2.1 using VIN -> make: wR2.1.1(VIN,make) wR2.2.2(SSN,VIN) final set of relations


Download ppt "1 Classroom Exercise: SQL u Consider a bookstore database with this schema: w Books(bookid, title, author, year) w Customers (customerid, name, email)"

Similar presentations


Ads by Google