Database Languages
eXercise #2
Relational Diagrams
Download
an Access2000 Version of this exercises database tables
1.
Closely Examine the tables that follow:
PEOPLE
Name |
Sex |
BirthYr |
MarriageYr |
Fred |
M |
1962 |
1986 |
Barney |
M |
1964 |
? |
Wilma |
F |
1958 |
1987 |
Olivia |
M |
1969 |
1990 |
Mergatroid |
F |
1975 |
1971 |
Popeye |
M |
1935 |
? |
Alexander |
M |
? |
1983 |
|
GRADUATIONS
Name |
GradYr |
Wilma |
1990 |
Olivia |
1986 |
Alexander |
1989 |
|
Constraint:
No one can appear in the GRADUATIONS table without first appearing in
the PEOPLE table
(a) Identify the
PRIMARY KEYs of the two tables (assuming the populations are significant).
(b) Draw Relational
diagrams (and attempt the SQL equivalent) for the following queries: (asterisks indicate complexity of question)
- the entire PEOPLE
table
- the name of all
people in the database (assuming the constraint has been upheld)
- the name and
sex of each person
- the name of all
females
- the name of any
male born after 1970, along with his birth year
- all married persons
- anyone for whom
we do not know a marriage year
- people who are
missing either a marriage or birth year
- a list of all
years recorded in the people table (either in the Birth or marriage
cols) *
- years in which
there was at least one graduation and marriage **
- anyone who is
not recorded as having graduated ***
- anyone who violates
the constraint ***
- people who were
married in the same year they graduated ***
2. Given the following
single column table called DIGITS:
Draw
relational diagrams (and attempt the SQL) for the following (hint: Join queries will solve these questions):
- all 2 digit numbers
between 00 and 99
- all 2 digit numbers
between 50 and 99
- all 2 digit couples
(eg. 11, 22, 33 ..)
- all 2 digit combinations
where the first digit is less than the second (eg. 23, 69)
3. Consider the
following tables which hold data about various video sub-systems available
for personal computers:
SYSTEMS
SystemId |
VidMode |
Cost |
PC-X37 |
CGA |
175 |
XLG45-1 |
EGA |
242 |
T55A |
EGA |
197 |
PS45610 |
VGA |
410 |
LQ-4432 |
SVGA |
793 |
1024i |
XVGA |
1345 |
ATI-W |
XVGA |
1407 |
|
RESOLUTIONS
VidMode |
Horiz |
Vert |
CGA |
320 |
200 |
EGA |
640 |
350 |
VGA |
640 |
480 |
SVGA |
800 |
600 |
XVGA |
1024 |
768 |
|
-
Identify
the PRIMARY KEYS for each of the tables
- Draw relational
diagrams, and then attempt the mSQL equivalents for the following
queries:
- systems with
a horizontal resolution better that 640
- the name
and cost of all 800x600 systems
- the cost
and resolution (horiz and vert) of the LQ-4432 system
- the name
and cost of systems with better than VGA resolution
Solutions