Download University of Linköping, Department of Computer Science

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Global serializability wikipedia , lookup

Database wikipedia , lookup

Microsoft Jet Database Engine wikipedia , lookup

Extensible Storage Engine wikipedia , lookup

Relational model wikipedia , lookup

Serializability wikipedia , lookup

Clusterpoint wikipedia , lookup

ContactPoint wikipedia , lookup

Database model wikipedia , lookup

Concurrency control wikipedia , lookup

Transcript
LiU, Linköping University
IDA, Department of Computer and Information Systems
Jose M. Peña
2009-08-05
EXAM
TDDD12 Database technology
TDDB48 Database technology
TDDC94 Database technology
12 august 2009, 14.00-18.00
Room
TER1 and TER2
Help
Dictionary, calculator.
Grades
You can get max 30 points. To pass the exam, grade 3, you need 7,5 points in each of the two
parts of the exam (Theory and Practice). For grade 4 and 5, you need 21 and 27 points,
respectively.
Questions
During the exam, there is possibility of asking questions and clarifications from Lena
Strömbäck, tel. 0709396776, who will visit the room at 15.00, and from Jose M. Peña, tel.
0708229596, who will visit the room at 17.00.
Instructions
Write clearly. Give relevant and motivated answers only to the questions asked. State the
assumptions you make besides those in the questions. None of these additional assumptions
should change the spirit of the exercises. You can answer in Swedish or English.
Good luck!
1(5)
Part 1: Practice
Exercise 1. EER modeling (4 p):
We want to create a database to store information about chess players and chess matches. The
players are swedish or non-swedish. The database should store information only about those
matches where at least one of the players is swedish. The information to store is when the
match took place, which two players took part in it, and all the chess moves in the match as
well as all the pieces captured during the match. A chess move is described by the order of the
movement in the match together with a code. The code always follows the pattern “pxy”,
which means that the piece p is moved to the square (x,y). We assume that each player plays
at most one match per day. If a move captures a piece, then which piece got captured should
be stored in the database.
Create an EER model for the scenario above. It suffices to use the following five attributes:





Player’s personal number.
Match’s date.
Move’s order in the match.
Move’s code.
Captured piece’s name.
Motivate the choice of entities, relationships and attributes. Write down all assumptions and
give cardinalities for the relationships.
Exercise 2. Translation to relational model (4 p):
Batt
Catt
B
C
1
1
D
N
Datt
ER
Eatt
o
F
1
G
H
N
2(5)
Translate the EER diagram above to relations. Mark the primary keys with solid underlining
and the foreign keys with dotted underlining and an arrow from the foreign key to the
attribute(s) pointed by the foreign key.
Exercise 3. SQL (1 + 1 + 2 + 1 = 5p):
Team
id name
arena
Player
id name
position age
Playing
id team
player
founded
season
points
team is a foreign key referencing to id in table Team.
player is a foreign key referencing to id in table Player.
One player only can play for one team in a season.
points is the total number of points a player has scored in the season.
1. List all the teams founded before “LiU Club”.
2. List the average age of all players that played for “LiU Club” in the season 08/09.
3. For each team, list the average age of all players playing in the season 08/09.
4. For each player who is younger than Magnus Johansson, list the number of seasons they
have played for “LiU Club”. (Some junior players may have not played in any season yet!)
Exercise 4. Normalization (2p):
Normalize (1NF2NF3NFBCNF) the relation R(A, B, C, D, E, F) with functional
dependencies F={CA, ABCD, BEF}. Give results after each step.
3(5)
Part 2: Theory
Exercise 5. Index (4 + 2 = 6p):
Assume a data file has 1,000,000 records. The file is ordered on the key field A. The size of
each record is 100 bytes. The disk block is of size 4096 bytes, and records are stored
unspanning. The index record is of size 10 bytes. A database application always needs to
query records randomly based on a key field B.
a) Illustrate how a single level index can speed up accessing data for this application. You
need to make a sketch of your solution and calculate the blocks accesses needed for a query.
b) Illustrate how a multiple level index speeds up accessing data comparing to the single level.
You need to make a sketch of your solution and calculate the blocks accesses needed for a
query.
Exercise 6. Transactions and concurrency (1 + 1 + 2 + 1 = 5p):
a) Database transactions are required to follow the ACID restrictions. Explain briefly
what is meant by this and what properties are required by a transaction.
b) Study the following transaction schedule:
T1: read(A)
T1: A:=A+100
T2: read(A)
T2: A:=A-500
T2: write(A)
T1: write(A)
Why does not this schedule follow the ACID restriction? Give at least one example of
a problem with the schedule and relate your example to one of the properties.
c) Explain the problem with the schedule in b using conflict serializability.
d) Give an alternative schedule for the transactions in b that fulfils the requirements for
conflict serializability.
Exercise 7. Database recovery (3 + 1 = 4p):
a) Describe the method for database recovery with immediate update that works for the
system log given below. Use the system log below to exemplify the method. Show all
operations that are performed when recovering the database. In the right order!
b) Would the use of checkpoints be advantageous for recovery with this method? Explain
your answer.
Part of system log:
Start-transaction T1
Write-item T1, A, 10
Start-transaction T2
Write-item T1, B, 10
Write-item T2, C, 10
Commit T1
Start-transaction T3
Write-item T3, D, 20
4(5)
Write-item T2, C, 20
Commit T2
system crash
5(5)