Homework Assignment 1 - Database Systems I | CMPS 180, Assignments of Database Management Systems (DBMS)

Material Type: Assignment; Class: Database Systems I; Subject: Computer Science; University: University of California-Santa Cruz; Term: Fall 2003;

Typology: Assignments

Pre 2010

Uploaded on 08/19/2009

koofers-user-8hr
koofers-user-8hr 🇺🇸

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 1
Due in class on 21st 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.2, page 127 of textbook.
2. Consider the following schema:
Invoices(invoice-no, cust-id, date)
Customers(cust-id, name, since, zipcode)
Items(invoice-no, item-no, qty, price)
The relation Invoices contains for each invoice, the id of the customer who made that invoice and the
date that invoice was made. The customer name, the date the customer made her first purchase, and
the zipcode where the customer resides is stored in the Customers relation. Each invoice contains
one or more purchased items. For every item purchased in an invoice, the quantity and price of that
item are also stored in the Items relation.
Write the following queries in relational algebra. Use only the relational operators taught in class so
far. If your relational algebra expression is huge, please break it down into smaller parts and explain
each part.
Find the names of all customers who made some purchases during the day “11/22/02”.
Find all invoices made during the days “11/22/02” and “11/23/02”.
Find the names of all customers who made invoices during the days “11/22/02” and “11/23/02”.
You may assume that there is a relation R(date) with two tuples “11/22/02” and “11/23/02”. Can
R be constructed from Invoices?
Find the names of all customer who made only one invoice during the date “11/22/02”. (Note:
The customer must make exactly one invoice.)
Find the item number of the most expensive item in the invoice “N0938”.
3. Consider the following schema:
1
pf2

Partial preview of the text

Download Homework Assignment 1 - Database Systems I | CMPS 180 and more Assignments Database Management Systems (DBMS) in PDF only on Docsity!

CS180 Database Management Systems - Winter 2003

Homework Assignment 1

Due in class on 21st 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.2, page 127 of textbook.
  2. Consider the following schema: Invoices(invoice-no, cust-id, date) Customers(cust-id, name, since, zipcode) Items(invoice-no, item-no, qty, price)

The relation Invoices contains for each invoice, the id of the customer who made that invoice and the date that invoice was made. The customer name, the date the customer made her first purchase, and the zipcode where the customer resides is stored in the Customers relation. Each invoice contains one or more purchased items. For every item purchased in an invoice, the quantity and price of that item are also stored in the Items relation. Write the following queries in relational algebra. Use only the relational operators taught in class so far. If your relational algebra expression is huge, please break it down into smaller parts and explain each part.

  • Find the names of all customers who made some purchases during the day “11/22/02”.
  • Find all invoices made during the days “11/22/02” and “11/23/02”.
  • Find the names of all customers who made invoices during the days “11/22/02” and “11/23/02”. You may assume that there is a relation R(date) with two tuples “11/22/02” and “11/23/02”. Can R be constructed from Invoices?
  • Find the names of all customer who made only one invoice during the date “11/22/02”. (Note: The customer must make exactly one invoice.)
  • Find the item number of the most expensive item in the invoice “N0938”.
  1. Consider the following schema:

R(A, B, C, D),

S(A, B, C, D),

T (B, E, A, B), where (A, B) is a foreign key that references S. What are the keys of the result of each query below? Provide only the smallest set of attributes that form the key. Note that the keys you specify must hold for the query evaluated on every possible instances of R, S, and T.

  • σA> 20 ∧C=“c′′ (R)
  • σA≥ 0 ∧B=“b′′ (R)
  • πA,B,C (R)
  • πA,D(S)
  • R ∩ S
  • R ./ T
  • R ∪ S
  • R − S
  • T ./ S
  • πA,B′,C,D′^ (R ./ ρA→A′,B→B′,C→C′,D→D′^ (S))
  1. Using the following parent-child relation schema PC(Parent, Child),
  • Find all grandparents of “Joe”.
  • Find all pairs of persons that are at most three generations apart. For example, “Joe” is two generations apart from his grandparents.
  1. Prove or disprove the following.
  • σC (πA(R)) = πA(σC (R)) where C is a condition on involving the attribute A only. You may assume a relation schema R(A, B).
  • (R ∪ S) ./ T = (R ./ T ) ∪ (S ./ T )
  1. Is the following set of relational operators, σ, π, ./ (natural join), ∪, −, ρ relationally complete? Justify your answer.