Database Management Systems Homework Assignment 2 - Winter 2003, Assignments of Database Management Systems (DBMS)

Instructions and questions for homework assignment 2 of the cs180 database management systems course offered in winter 2003. The assignment includes exercises from the textbook and database schema-related queries.

Typology: Assignments

Pre 2010

Uploaded on 08/19/2009

koofers-user-pwy
koofers-user-pwy 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS180 Database Management Systems - Winter 2003
Homework Assignment 2
Due on 28 Jan 2003
(Late homeworks will not be accepted.)
Instructions: Answer all the questions concisely below. Points will be taken off for unnecessarily long
answers. Please remember to include your name, student-id number, and email address in your homework
submission.
1. Exercise 4.3 of textbook, page 127.
2. Exercise 5.4 of textbook, page 176.
3. Assume the following schema Rating(cid, name, rating) which shows the name of the movie that a
customer watches and the rating that the customer gives for that movie.
For each of the given condition below, find the smallest instance of Rating that will fail the condition.
Also, find the smallest instance of Rating that will satisfy the condition.
rRating (r.rating < 6r.cid = J ohn”)
rRating r.rating = 10
4. Are the following SQL queries equivalent? If yes, provide a short proof of why they are equivalent.
If no, provide a counter-example. You may assume that the relational schema is R(A, B) and S(A, B).
SELECT *
FROM R r
WHERE r.A IN (SELECT s.A
FROM S s
WHERE s.B < 10)
SELECT *
FROM R r, S s
WHERE r.A = s.A AND s.B < 10
5. How many possible instances are there for the relational schema R(A:boolean, B:boolean, C:boolean),
S(A:boolean, B:boolean)?
6. Consider the following simple relational schema for an internet bookshop: Authors(aid, name, age,
affiliation), Publications(id, title, year), PublishersPub(pid, id), PubAuthors(id, aid), Sales(id, year,
qty)
You may assume that each publication is published by only one publisher. Moreover, a publication
may be made by one or more authors and each author may make more than one publication.
1
pf2

Partial preview of the text

Download Database Management Systems Homework Assignment 2 - Winter 2003 and more Assignments Database Management Systems (DBMS) in PDF only on Docsity!

CS180 Database Management Systems - Winter 2003

Homework Assignment 2

Due on 28 Jan 2003

(Late homeworks will not be accepted.)

Instructions : Answer all the questions concisely below. Points will be taken off for unnecessarily long answers. Please remember to include your name, student-id number, and email address in your homework submission.

  1. Exercise 4.3 of textbook, page 127.
  2. Exercise 5.4 of textbook, page 176.
  3. Assume the following schema Rating(cid, name, rating) which shows the name of the movie that a customer watches and the rating that the customer gives for that movie. For each of the given condition below, find the smallest instance of Rating that will fail the condition. Also, find the smallest instance of Rating that will satisfy the condition. - ∀r ∈ Rating (r.rating < 6 → r.cid = ”John”) - ∃r ∈ Rating r.rating = 10
  4. Are the following SQL queries equivalent? If yes, provide a short proof of why they are equivalent. If no, provide a counter-example. You may assume that the relational schema is R(A, B) and S(A, B). SELECT * FROM R r WHERE r.A IN (SELECT s.A FROM S s WHERE s.B < 10)

SELECT *

FROM R r, S s WHERE r.A = s.A AND s.B < 10

  1. How many possible instances are there for the relational schema R(A:boolean, B:boolean, C:boolean), S(A:boolean, B:boolean)?
  2. Consider the following simple relational schema for an internet bookshop: Authors(aid, name, age, affiliation), Publications(id, title, year), PublishersPub(pid, id), PubAuthors(id, aid), Sales(id, year, qty) You may assume that each publication is published by only one publisher. Moreover, a publication may be made by one or more authors and each author may make more than one publication.

For each of the following, write a TRC or DRC query. If a relational calculus query cannot be used to answer the question, write an SQL query to answer the question. If an SQL query is given as an answer when it can be answered with a relational calculus query, no credit will be given. If your answer is huge, please explain each part. Again, no credit will be given for unexplained answers.

  • Find the names of authors who published in the year 2001.
  • Find the names of authors who made at least 3 publications in the year 2001.
  • Find the most popular publisher in the year 2001. The most popular publisher is the publisher who made the most sales.
  • Find the most popular publication sold in 2001.
  • Find the names of authors who have written exactly one book.
  • Find the total number of sales made for every publisher and every year where the publisher made more than two distinct publication sales that year.