Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

create table CUSTOMER ( CID text primary key, NAME text, DOB date ); create table BOOK ( ISBN text primary key, TITLE text, AUTHOR text

create table CUSTOMER (

CID text primary key,

NAME text,

DOB date );

create table BOOK (

ISBN text primary key,

TITLE text,

AUTHOR text );

create table BUYS ( BID UUID primary key,

CID text foreign key references CUSTOMER,

ISBN text foreign key references BOOK,

DATE timestamp,

PRICE float );

--------------------

Write the following queries in Relational Algebra (RA). You may use any of the operators mentioned in class or the text, including ,, , , /, , , and . N.B. When the question says d X" where X is a relationship or entity, that means to return the primary key for X, unless otherwise specified.

(a) Find books written by `Sam Spade'.

(b) Find customers who are currently teens (i.e. ages 13 to 19, inclusive).

(c) Find customers who are teens and bought at least one book by `Sam Spade'.

(d) Find customers who are teens and bought every book by `Sam Spade'.

(e) Find purchases that cost more than $100.

(f) Find the names of customers that bought more than $100 worth of books in 01/2021.

(g) Find pairs of customers that have purchased exactly the same set of books.

(h) Find customers that have purchased exactly three books so far in 2021.

(i) Find customers that have purchased more books than everyone else.

(j) Find the names of customers that have never purchased a book.

2. Given R(A, B, C) and S(B, D), prove or disprove the following RA propositions. Assume all columns have the same domain (e.g. strings).

(a) B,C(R) S = B,C,D(R S).

(b) If A B holds for instances of R, then AB(A,c (R)) S = B,C(R) S.

(c) If A B holds for instances of R, then A,B (R) A,c (R) = R

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

=+ How well do you think you could do your job?

Answered: 1 week ago