You are on page 1of 7

Exercise

1:
ER
Diagrams

Due: November 14, 2005


This exercise should be submitted to the course box. Remember to write your logi
n!

Problem
0
(0
Points)

Registerforthedatabase course usingthe urlhttp://httpdyn.cs.huji.ac.il/course-ad


min/db/register.
Problem
1
(20
points)

Below we present several entity-relationship diagrams that model information mai


ntained by a rental
company about its tenants, apartments, and building managers. Note that tid is t
he key for Tenants,
apid is the key for Apartments, and mid is the key for Managers. For each of the
entity-relationship
diagrams below:
(a)
State briefly the meaning of the diagram. Emphasize the constraints in the diagr
ams.
(b)
Suppose that there are400tenants,150 apartments, and30 managers. Whatis the maxi
mal
number
of tuples that the relation Rents contains?
(c)
Suppose that there are400 tenants, 150 apartments, and30 managers. Whatis the mi
nimal
number
of tuples that the relation Rents contains?
Note
that
the
thick
lines
are
participation
constraints.

Figure 1:
(Sticky Note comment Indeterminate
blank)
ApartmentsManagersTenantsRentsmidapidtid
Figure 2:

(Sticky Note comment Indeterminate


blank)
ApartmentsManagersTenantsRentsmidapidtid
Figure 3:

(Sticky Note comment Indeterminate


blank)
(Sticky Note comment Indeterminate
blank)
1
Figure 4:

(Sticky Note comment Indeterminate


blank)
ApartmentsManagersTenantsRentsmidapidtid
(Sticky Note comment Indeterminate
blank)
(Sticky Note comment Indeterminate
blank)
(Sticky Note comment Indeterminate
blank)
ApartmentsManagersTenantsRentsmidapidtid
Problem
2
(20
Points)

1. As in Problem 1, we consider information about apartments, tenants, and build


ing managers. We
wish to store information about what apartment each tenant rents. And for each r
ented apartment
we would like to know who manages it. Two basic approaches can be taken to model
this informat
ion. One option is to use a single relationship between all three entities. The
other option is to
use two binary relationships. Here are the 2 diagrams that might be used:
(Sticky Note comment Indeterminate
blank)
ApartmentsManagersTenantsRentsmidapidtidApartmentsManagersTenantsRentsmidapidtid
Manages
(a) Assuming that there are no further constraints on the information, can the i
nformation be
captured in both diagrams? Explain.
(b) Suppose that each apartment is managed by at most one manager. Can you add e
dge cons
traints to the diagram on the left in order to capture this information? What ab
out the
diagram on the right? Explain.
2. Assuming therearenofurtherconstraints,isthereanything wrong with using thefol
lowingdiagram
to model the information?
(Sticky Note comment Indeterminate
blank)
(Sticky Note comment Indeterminate
blank)
(Sticky Note comment Indeterminate
blank)
ApartmentsTenantsRentsmidapidtid
(Sticky Note comment Indeterminate
blank)
2
Problem
3:
ER
Modeling
(60
Points)

You are asked to model a certain security trading situation. Below is the list o
f requirements:

A company is uniquely determined by its name and headquarters address. We are co


ncerned only
with companies that have publicly traded common stocks. Each such company has on
ly one such
stock. Include the number of shares outstanding in your model.
Every stock trades on one or more exchanges. An exchange is uniquely determined
by its name.
A stock has a symbol under which it trades on an exchange. The same stock may ha
ve different
symbols on different exchanges.
An option on a stock symbol is a security that is uniquely determined by its typ
e, stock symbol,
strikeprice, and expirationdate. An optiontrades onthe same exchange asits stock
symbol. The
type of an option is either a put or a call . It can not be both, and it can not be s
omething else.
Include the last trading price and current daily volume for every symbol and opt
ion. You do not
need toincludehistorical trading info(such aspast closingprices).
Securities(i.e. stocksand options) areowned andtradedby traders. Atraderhasaname
and a
tax id. The tax id uniquely determines the trader.
Traders do not trade directly, but via brokerages. A brokerage is uniquely deter
mined by its name
and address.
Each brokerage deals with one or more exchanges and pays a fixed yearly fee to e
very exchange it
dealswith. Thefeecouldbedifferentforeverybrokerage/exchangepair. Includethefeein
your
model.
A trader owns at least one account with at least one broker. She may hold more t
han one account
with the same broker and deal with more than one broker. An account is uniquely
determined by
brokerage and account number. A brokerage may have no accounts. Each account has
exactly one
owner.
Accounts hold securities and cash. Note that a stock bought on one exchange coul
d be sold on
another, so it is stocks, not symbols, that are held. Do not forget to include o
ptions in accounts.
Traders place trading orders via their brokerages. An order specifies the accoun
t, exactly one
symbol or option to trade, bid (buy) or ask (sell), number of shares to trade, and t
he order
expiration. There are two types of orders: market and limit . A limit order has the l
imit price
in addition to the mentioned properties.
The brokerage and order id uniquely determine the order.
An order couldbeplaced onlyfor securities that are traded on the exchanges with
which thebroker
deals.
3
Atransactionis effectedin(possiblypartial) fulfillment oftwo orders. Every trans
action contains
the following information: exactly one bid order, exactly one ask order, number
of shares, transact
ion price, commissions paid by the buyer and the seller to their brokerages, and
the timestamp.
Exchange and transaction number uniquely determine the transaction.
Note that an order could be filled by several transactions.
Draw an entity-relationship diagram to model the information described above. Re
member to put in
constraints,key attributes, etc. Ifyou use theISA relationship, state any coveri
ng and overlap constraints
that hold. Make any necessary and logical assumptions. State any such assumption
s clearly. Also state
clearly allthe constraintsyou recognize,but unableto expressinthediagram.
For clarityyou may wanttopresentyourdiagram on several sheets. Similartothis:
Sheet 1:

(Sticky Note comment Indeterminate


blank)
WidgetGadgetMakes
Sheet 2:

(Sticky Note comment Indeterminate


blank)
Gadget

(Sticky Note comment Indeterminate


blank)
(Sticky Note comment Indeterminate
blank)
ISA

DoohickeyThingy
4