No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Latest commit c2218aa Oct 11, 2018
Permalink
Failed to load latest commit information.
README.md Update README.md Oct 11, 2018
hw2_template.pdf Add files via upload Oct 6, 2018
hw2_template.tex Update hw2_template.tex Oct 6, 2018

README.md

Homework 2

  • Assigned: 10/4
  • Due: 10/16 at 10:00AM via Gradescope
  • worth 3.75% of your grade

Highly recommend to draft your answers using this template (pdf, latex).

Update logs

10.11.2018

Added

  • 'You can answer relational algebra with sub steps.' is added to the description of 1. Relational Algebra.

10.08.2018

Added

  • 'Make sure your SQL can be executed.' is added to the description of 3. SQL.

10.05.2018

Changed

  • 2.5 T1 ⨝T1.A<T2.BB<=2(T2))

Added

  • 'Simply answer NULL if you believe the resulting table is empty or there are some errors with the expressions' is added to the description of 2. More Relational Algebra.

1. Relational Algebra

(2 points each, 4 points total)

Consider the simplified schema below (primary keys are in bold):

  • liquors(lid, name, price, manufacturer)

  • sales(month, seller, liquors, county, quantity)

Note: sales(liquors) references liquors(lid), and month is a text field (e.g. January, February).

Construct relational algebra for the following queries, you can answer relational algebra with sub steps:

  • Q1: Find the names of liquors that had at least one sale in "Clarke" or "Marshall" counties for the month of November.

  • Q2: Find the names of manufacturers that sold at least three different liquors during the month of January in "Marshall" county.

Note: Please use only operators covered in class. For Q2, it might help to think about the "at least two" case and then expand it to "at least three".

2. More Relational Algebra

(1 point each, 6 points total)

Simply answer NULL if you believe the resulting table is empty or there are some errors with the expressions.

Given the following tables

T1

A B C
1 x a
2 y b
2 z c

T2

B C D
1 x c
2 y c
3 x a

Write the result table for the relational algebra expressions:

  1. πA,B(T1)
  2. T1 × πA(T1)
  3. T1 ⨝T1.B=T2.C T2
  4. T1 − (T1 ∩ T2)
  5. T1 ⨝T1.A<T2.BB<=2(T2))
  6. T1 ⨝ (σB=c(T2))

3. SQL

Write the following relational algebra expressions in SQL. Make sure your SQL can be executed.

Note: You don't need to know the full schema to translate these statements.

  1. πname,age(Student)
  2. Student × πage(Student)
  3. Student ⨝Student.name=Teacher.name Teacher
  4. Student − (Student ∩ Teacher)
  5. year=2018(Student) )⨝Student.age<Teacher.agename=engene(Teacher))
  6. Student ⨝ (σage<=50(Teacher))

Submission

Submit a PDF file containing your answers to Gradescope.

Consider using a text editor. Scanned documents are fine, but make sure your answers are readable.