You are on page 1of 4

Appendix 1.

About educational databases


All exercises are performed on the databases described below.
1. Computer firm
The database scheme consists of four relations:
Product(maker,model,type)
PC(code,model,speed,ram,hd,cd,price)
Laptop(code,model,speed,ram,hd,screen,price)
Printer(code,model,color,type,price)
The relation "Product" shows the maker, model number, and type (pc, laptop, or printer). t is assumed
that model numbers are uni!ue for all the makers and product types. "ach model number specifyin# pc in
the relation "P$" is characteri%ed by speed (of the processor in &'%), total amount of (A& (in &b), hard
disk dri)e capacity (in *b), $+ (,& speed (for example, -.x-), and the price. The relation "/aptop" is
similar to that one of P$s except for the $+ (,& speed, which is replaced by the screen si%e (in inches).
0or each printer model in the relation "Printer" it is told whether the printer is color or not (color attribute
is -y- for color printers1 otherwise it is -n-), printer type (laser, 2et, or matrix), and the price.
2. Recycling firm
The firm has a few outlets that recei)e items for recyclin#. "ach of the outlets recei)es funds to be paid to
deli)erers. nformation on recei)ed funds is re#istered in a table:
Income_o(point,date,inc)
The primary key is (point, date), thus receipt of money (inc) takes place not more than once a day.
nformation on payments to deli)erers is re#istered in the table:
Outcome_o(point,date,out)
n this table the primary key (point, date) also ensures bookkeepin# of the funds distribution at each point
not more than once a day.
n case income and expenses may occur more than once a day, the followin# tables (primary key is code)
are used:
Income(code,point,date,inc)
Outcome(code, point, date, out)
3. Ships
The database of na)al ships that took part in 3orld 3ar is under consideration. The database has the
followin# relations:
Classes(class,type,country,numGuns,bore,displacement)
Ships(name,class,launched)
Battles(name,date)
Outcomes(ship,battle,result)
4hips in classes are arran#ed to a sin#le pro2ect. A class is normally assi#ned the name of the first ship in
the class under consideration (head ship)1 otherwise, the class name does not coincide with any ship
name in the database.
The $lasses relation includes the class name, type (bb for a battle ship, or bc for a battle cruiser), country
where the ship was built, number of main #uns, #un caliber (diameter of the #un barrel, in inches), and
displacement (wei#ht in tons). The 4hips relation includes the ship name, its class name, and launch year.
The 5attles relation co)ers the name and date of a battle the ships participated1 while the result of their
participation in the battle (sunk, dama#ed, or unharmed 6 ,7) is in the ,utcomes relation. 8ote: the
,utcomes relation may include the ships not included in the 4hips relation.
Appendix 2. The list of exercises (S!CT"
5elow is the list of all the first6phase exercises with the number of each exercise stated in the tasks, the
database number for these exercises, and the complexity le)el.
!"O #$S%IO"
9
0ind the model number, speed and hard dri)e capacity for all the P$s with prices below :;<<. (esult set:
model, speed, hd.
= 0ind printer makers. (esult set: maker.
> 0ind the model number, (A& and screen si%e of the laptops with prices o)er :9<<<.
. 0ind all the records from the Printer relation for color printers.
;
0ind the model number, speed and hard dri)e capacity of the P$s ha)in# 9=x $+ and prices less than :?<<
or ha)in# =.x $+ and prices less than :?<<.
? Point out the maker and speed of the laptops ha)in# hard dri)e capacity more or e!ual to 9< *b.
@ 0ind out the models and prices for all the products (of any type) produced by maker 5.
A 0ind out the makers that sale P$s but not laptops.
B 0ind the makers of the P$s that ha)e speed not less than .;<&'%. (esult set: &aker.
9< 0ind the printers ha)in# the hi#hest price. (esult set: model, price.
99 0ind out the a)era#e speed of P$s.
9= 0ind out the a)era#e speed of the laptops priced o)er :9<<<.
9>0ind out the a)era#e speed of the P$s produced by maker A.
9.
0or each )alue of speed find the a)era#e price of the P$ with the same processor speed. (esult set: speed,
a)era#e price.
9; 0ind the hard dri)e si%es that are e!ual amon# two or more P$s. (esult set: hd.
9?
0ind the pairs of P$ models ha)in# similar speeds and (A&. As a result, each resultin# pair is shown only
once, i.e. (i, 2) but not (2, i). (esult set: model with hi#her number, model with lower number, speed, and
(A&.
9@ 0ind the laptops ha)in# speeds less than all P$s. (esult set: type, model, speed.
9A 0ind the makers of the cheapest color printers. (esult set: maker, price.
9B
0or each maker find out the a)era#e screen si%e of the laptops produced by it. (esult set: maker, a)era#e
screen si%e.
=< 0ind the makers producin# at least three distinct models of P$s. (esult set: maker, number of models.
=9 +efine the maximal price of P$ produced by each maker. (esult set: maker, maximal price.
==
0or each )alue of P$ speed that exceeds ?<< &'%, define the a)era#e price of the P$s with identical speeds.
(esult set: speed, a)era#e price.
=>
0ind the makers producin# at least both a pc ha)in# speed not less than @;< &'% and a laptop ha)in#
speed not less than @;< &'%. (esult set: &aker
=. 0ind the model number of the product (P$, laptop, or printer) with the hi#hest price. (esult set: model.
=;
0ind the printer makers which also produce P$s with the lowest (A& and the hi#hest6speed processor
amon# P$s with the lowest (A&. (esult set: maker.
=? +efine the a)era#e price of the P$s and laptops produced by maker A. (esult set: sin#le total price.
=@
+efine the a)era#e si%e of the P$ hard dri)e for each maker that also produces printers. (esult set: maker,
a)era#e capacity of '+.
=A
+efine the a)era#e '+ si%e (sin#le )alue for all makers) of P$s produced by those makers that also produce
printers. (esult set: a)era#e si%e of '+.
&'
Cnder the assumption that the income (inc) and expenses (out) of the money at each outlet are written not
more than once a day, #et a result set with the fields: point, date, income, expense. Cse ncomeDo and
,utcomeDo tables.
() Cnder the assumption that the income (inc) and expenses (out) of the money at each outlet (point) are
re#istered any number of times a day, #et a result set with fields: outlet, date, expense, income. 8ote that
a sin#le record must correspond to each outlet at each date. Cse ncome and ,utcome tables.
>9 Point out the names and countries of the ship classes the #un caliber of which is not less than 9? in.
>=
+etermine names of all the ships in 4hips table that meet a combination of at least four criteria from the
followin# list: num*uns E A bore E 9; displacement E >=<<< type E bb launched E 9B9; class E 7on#o
country E C4A
>> +efine the ships sunk in battles in the 8orth Atlantic. (esult set: ship.
>.
n accordance with the 3ashin#ton nternational Treaty adopted in the be#innin# of 9B==, it was prohibited
to build battle ships with displacement more than >; thousand tons. +efine the ships which )iolate this
treaty (take into account only ships with known launched year). (esult set: ship name.
>; Point out the names, displacements and number of #uns of ships participatin# in the battle at *uadalcanal.
>? /ist the names of head ships in the database (takin# into account ,utcomes table).
>@ 0ind the classes includin# only one ship in the database (takin# into account ,utcomes table).
>A 0ind the countries ha)in# classes of both ordinary ships and cruisers.
>B +efine the ships that "sur)i)ed for future battles"1 bein# dama#ed in one battle, they took part in another.
.< 0ind the class, name and country for the ships in 4hips table, which ha)e not less than 9< #uns.
.9 +efine the names of all the ships in the database which were definitely launched before 9B.9.
.= 0ind the names of ships sunk in battles and the names of correspondin# battles.
.>
0or each country, find the year, in which the maximal number of ships had been launched. n the case of
more than one year in !uestion, take a minimal year. (esult set: country, number of ships, year
.. 0ind all ship names be#innin# with letter "(".
*+ 0ind the all ship names consistin# of three or more words (for example 7in# *eor#e F)
.? Point out the battles in which at least three ships from the same country took part.
.@
0ind inlets with #reater total payout in different pairs of inlets with e!ual inlet 8o-s from outcome and
outcomeDo tables considerin# only those dates when waste was collected at least at one of the inlets
in)ol)ed. (esult set: nlet G, date, text: 6 "once a day", if daily reportin# inlet is in the lead1 6 "more than
once a day", if se)eral times a day reportin# inlet is in the lead1 6 "both", for draw cases.
.A 0ind the ship classes which ha)e at least one ship sunk in battles.
.B 0ind the names of the ships ha)in# the #un caliber of 9? in (takin# into account ,utcomes table).
;<
The wei#ht of a #un missile (in pounds) is almost e!ual to one6half cube of its caliber (in inches). +efine the
a)era#e wei#ht of the missile for the ships of each country (takin# into account ,utcomes table).
;9
0ind the names of the ships ha)in# the lar#est amount of #uns amon# all the ships with the same
displacement (takin# into account ,utcomes table).
;=
A scrap recyclin# company is settin# up its collection inlets- network. "ach inlet #ets a :=<<<< startin#
capital. The ob2ecti)e is to increase the initial capital to 9;<H of the startin# )alue, based on daily reportin#
(i.e. only ,utcomeDo table is to be used). 4uppose inlets operate with =<<H profitability, i.e. earn := on
each dollar paid for turned6in scrap. 0ind the followin#: 6 0or inlets that ha)e achie)ed the #oal, find the
achie)ement date and surplus money accumulated. 6 0or the ones fallin# short, return last workin# dayIs
shorta#e sum. (esult set: nlet +, achie)ement date (or last workin# day), surplus (or shorta#e) )alue.
;> To within two decimal di#its, define the a)era#e amount of #uns for the battleship classes.
;.
To within two decimal di#its, define the a)era#e amount of #uns for all the battleships (takin# into account
,utcomes table).
;; 0or each class, define the year in which the first ship of this class was launched. (esult set: class, year.
;?
0or each class, define the number of ships of this class that were sunk in battles. (esult set: class, number
of sunked ships.
;@
0or each class, consistin# of at least three ships, define the number of ships (that must be at least 9) of this
class sunk in battles. (esult set: class, number of sunken ships.