The database has relations bank-robbed (which stores information about banks that the gang has already robbed), bank- to-rob (which stores information about banks that the gang plans to rob), member (which stores information about gang members), and has-robbed (which stores information about which gang members have participated in robberies of what banks). Note that the gang may be planning to rob a bank that they have already robbed one or more times in the past. The schemes of these relations are:
Bank-robbed-scheme = (name: string, address:string,
number-of-depositors:integer)
Bank-to-rob-scheme = (name: string, address:string,
number-of-depositors:integer)
Member-scheme = (name:string, address:string, years-in-prison:integer,
banks-at:string, skill1:skilltype, skill2:skilltype)
Has-robbed-scheme = (member-name:string, bank-name:string,
date:string, amount:real)
where attribute banks-at of member is the name of the bank where the gang member does his or her banking, and skilltype is an enumerated type consisting of {lock-picking, shooting, driving, counting-money, public-relations}.
create table
command part of SQL's DDL, DML, both, or neither?Customer-scheme = (name, address, cust-num) Flyrod-scheme = (manufacture, length, line-weight, flyrod-stock-num) Purchased-scheme = (cust-num, flyrod-stock-num, date)
select manufacturer, line-weight, date from customer, purchased, flyrod where customer.cust-num = purchased.cust-num and purchased.flyrod-stock-num = flyrod.flyrod-stock-num and name = "Elvis Presley"
cust-num
s of every customer who has purchased
at least one flyrod made by each of the manufacturers represented in the
flyrod
relation. (Hint: first write a query that returns a relation
associating a customer's cust-num
with all of the manufacturers of
flyrods that the customer has purchased.)
flyrod
relation. Use any reasonable domains
for
the attributes. Your answer should specify that flyrod-stock-num
is the primary key for relations on Flyrod-scheme
, and should also
specify the domain constraint that is always associated with any primary
key in SQL.
flyrod
relation.
Part-scheme = (part-num, description, groovyness, quantity) Supplier-scheme = (supplier-name, address, phone-number) Supplies-scheme = (part-num, supplier-name, address, cost)The primary key for relations on
Part-scheme
is part-num
, and
the primary key for relations on Supplier-scheme
is
{supplier-name, address}
.
groovyness
and the cost
of parts.
groovyness
of each part with its cost
. Note that the same part can cause multiple
tuples to be part of this view if that part has multiple suppliers.
groovyness
is expressed as an integer between
1 and 10. Use SQL to write a query that returns the average cost
of
a part at each level of groovyness
, and the groovyness
associated
with that cost
. (Hint: the view you defined should be useful for
doing this.)
supplies
as a
relationship set from supplier
to part
(E-R model), what is
the mapping cardinality of this relationship set?
Supplies-scheme
be?