Вы находитесь на странице: 1из 9

ADBMS-PRACTICE QUESTIONS

Question 1

A distributed database system is defined as:


“a distributed database system consists of a collection of sites, connected together
via some kind of communications network, in which:
a. Each site is a full database system site in its own right, but
b. The sites have agreed to work together so that a user at any site can
access data anywhere in the network exactly as if the data were all stored
at the user’s own site.”
(a) Outline the four advantages and three problems in using distributed database
systems.
[7 Marks]

(b) Briefly discuss why data fragmentation could be useful in such distributed
database systems, and explain each of the following fragmentation rules:
 Completeness
 Reconstruction
 Disjointness
[8 Marks]

(c) Demonstrate in detail how these rules are enforced when performing
horizontal and vertical fragmentation, by using the STUDENT relation given
below:

[10 Marks]

Question 2

The following is the relational schema of part of the database that Acme Pty Ltd recently
implemented:

DEPARTMENT (DeptNo, Name, Location)


EMPLOYEE (EmpNo, Name, Street, City, Postcode, HireDate, Salary, DeptNo)
LEAVE (EmpNo, FromDate, ToDate)
EMPQUAL(EmpNo, QualID)
QUALIFICATION(QualID, Qualification, Institution)

Using the above schema, write SQL queries that will answer/process the following:

a. List all cities where an employee lives. Only show the city once.
b. What is the lowest salary paid for any employee that lives in the city of
Melbourne?

1
c. For each qualification, show the total number of employees that have that
qualification. Show qualification id, qualification and the total number.
d. List any employees who are on annual leave on 01/08/2001. Note, date format is
#01-08-2001#. Show employee number only.
e. What is the total salary cost incurred by Acme for employees in the Marketing
department?
f. List the employee(s) with the highest salary. Show employee number and name.
g. List the employee names and all of the institutions that they have studied at.
h. How many employees have no qualifications?
i. Delete all leave rows if the leave ended prior to the start of this year.
j. Increase the salary of all employees by $80

[2+2+2+2+2+2+2+2+2+2=20 marks]

Question 3

Within the area of database and DBMS

a. What does ‘locking’ mean? Why is it used?


b. What is meant by ‘deadlock’?
c. Discuss ways in which a DBMS could try to cope with a deadlock.

Question 4

(a) In the context of concurrency control for a multi-transaction database


system, briefly discuss the concept of lock and deadlock, and their
relationship.
[8 Marks]

(b) Consider the following two interleaved transactions A and B which might
occur in a database system for a bank.
Mr Smith’s bank account, with an initial balance of $1000, is being
updated simultaneously by two transactions A and B in the order
shown below:
1. Transaction A retrieves the account balance
2. Transaction A transfer out $300 from the account and updates
the account balance.
3. Transaction B retrieves the account balance.
4. Transaction B transfer $200 into the account
5. Transaction A executes a rollback.
6. Transaction B commits the transaction.

2
Answer the following questions
(i) Show the step-by-step changes to the account balance and the final
balance of the account, if transaction A and B were performed
according to the sequence shown above.
[4 Marks]

(ii) Show the step-by-step changes to the account balance and the final
balance of the account, if transactions A and B were performed in a
serial sequence (i.e., Transaction A completes all its operations before
Transaction B starts).
[4 Marks]

(iii) Identify the type of concurrency problem occurred in the transaction


sequence used for (i) above, and explain how the problem arises.
[2 Marks]
(iv) Provide a step-by-step solution using locking to show how the two
transactions would be executed, if appropriate concurrency control
were applied to the system.
[7 Marks]

Question 5

Data replication is an important mechanism commonly employed in a distributed


database environment. Replication provides a number of benefits in terms of
enhanced system performance.

(a) Discuss the role that data replication plays in distributed database
management systems.
[7 Marks]

(b) Explain the effect that replication has on read-only and update transactions.
[4 Marks]

(c) Give details of two strategies for performing updates in a replicated distributed
database environment. State one disadvantage of each strategy.
[6 Marks]

3
(d) The components of a Distributed Database include the following: Network
Processor, Remote data processor, Data dictionary, and local data processor.
Explain the function of each of the above components.

[8 Marks]

QUESTION 6

(a) Describe the three concurrency problems in a multi-user database systems,


giving one example for each of the concurrency problems. [9 Marks]
(b) The following list represents the sequence of operations in an interleaved
execution of a set of transactions T1, T2, …T12 in a concurrency system based
on locking, where A, B, …H are the data items. Assume that Fetch A (if
successful) acquires an S lock on A, subsequent Update A (if successful)
promotes that lock to an X-Lock, and all locks are held until end-of-transaction.
time Transaction operation
Time t0
time t1 T1 Fetch A
time t2 T2 Fetch B
time t3 T4 Fetch D
time t4 T5 Fetch A
time t5 T2 Fetch E
time t6 T2 Update E
time t7 T3 Fetch F
time t8 T2 Fetch F
time t9 T5 Update A
time t10 T1 COMMIT
time t11 T6 Fetch A
time t12 T5 ROLLBACK
time t13 T6 Fetch C
time t14 T6 Update C
time t15 T7 Fetch G
time t16 T8 Fetch H
time t17 T9 Fetch G
time t18 T9 Update G
time t19 T8 Fetch E
time t20 T7 COMMIT
time t21 T9 Fetch H
time t22 T3 Fetch G
time t23 T10 Fetch G
time t24 T9 Update H
time t25 T6 COMMIT
time t26 T11 Fetch C

4
time t27 T12 Fetch D
time t28 T12 Fetch C
time t29 T2 Update F
time t30 T11 Update C
time t31 T12 Fetch A
time t32 T12 Update D
time t33 T4 Fetch G
time t34

(i) Determine whether there are any deadlocks at time t34 by providing a
Wait-For-Graph. [12 Marks]
(ii) Discuss how the system could recover if it were deadlocked at time t34
and justify your choice of ‘victim’ transaction(s). [4 Marks]

QUESTION 6

(a) The term Security refers to the protection of the database against unauthorized
access, either intentional or accidental.
(i) Define the two main approaches of a security rule.
[3 Marks]

(ii) Define a security rule, by using the view mechanism, such that the user
Fred is allowed to see (i.e select) the name, the address and the job title
of each employee of status less than 100, for the following database:
[7 Marks]
CREATE TABLE Employee (
Emp_id CHAR(10),
Name VARCHAR(30),
Address VARCHAR(80),
Job_title VARCHAR(30),
Job_type CHAR(10),
Salary INT,
PRIMARY KEY (Emp_id)
FOREIGN KEY (Job_type) REFERENCES Status_def ) ;
CREATE TABLE Status_def (
Job_type CHAR(10),
Status INT,
PRIMARY KEY (Job_type, Status) ) ;

Question 7

5
Concurrency is defined as the process of managing simultaneous operations on the
database without having them interfere with one another.
(i) Describe one of the possible problems generated by concurrent access to the
same data. Support your answer with appropriate diagram and explanation.
[5 marks]
(ii) Illustrate how the problem can be resolved by using the locking mechanism.
[4 marks]
(iii) Can there be any additional problems that can occur using the locking
mechanism? If Yes, then how could they be resolved?
[4 marks]
(iv) Produce a wait-for graph for the following transaction scenario, and determine
whether deadlock exists. If there is a deadlock, explain how the deadlock can
be broken. Give a reason for choosing the victim.
[12 marks]

Transaction Data items locked by Data items transaction is waiting


transaction for
T1 X2 X1, X3
T2 X3,X10 X7, X8
T3 X8 X4, X5
T4 X7 X1
T5 X1,X5 X3
T6 X4,X9 X6
T7 X6 X5

T1 – stands for Transaction 1


X1 – stands for data item X1

6
Question 8
(a) A distributed database (DDB) is a collection of multiple, logically interrelated
databases which are physically distributed over a computer network”
(i) Give three advantages of a Distributed Database as compared to a
centralized database.
[6 marks]
(ii) Differentiate between a Homogeneous DDB and a Heterogeneous
DDB and explain under what circumstances would such systems
generally arise?
[6 marks]
(iii) Discuss some of the advantages of having data replicated at various
sites.
[3 marks]

QUESTION 9

(a) “A distributed database (DDB) is a collection of multiple, logically interrelated


databases which are physically distributed over a computer network”
(i) Give three advantages of a Distributed Database as compared to a centralized
database.

[3 marks]

(ii) The components of a Distributed Database include the following: Network


Processor, Remote data processor, Data dictionary, and local data processor. Explain
the function of each of the above components.

(b) Discuss the idea of query processing in distributed databases using the example given
below.

Consider three relations


Books(Book_ID, Title, Author, Year)
Libraries(Lib_ID, Location)
Availability(Book_ID, Lib_ID) – existing books in libraries
Suppose these relations are implemented in a distributed database system. Suppose that the
first two relations – Books and Libraries– are stored at site A and the last relation –
Availability – is stored at site B. Suppose the following query is issued at site C (select all the
books published in 1999 stored at the libraries in London)

SELECT *

7
FROM Books B, Libraries L, Availability A
WHERE B.Book-ID = A.Book-ID AND L.Lib-ID = A.Lib-ID
AND Year = ‘1999’ AND Location = 'London' ;

[14 marks]

QUESTION 10

(a) Describe the three types of potential mistake which could occur if concurrency control is
not properly enforced in the database system. Support your answer with appropriate
example for each.
[9 marks]

(b) Describe the data access protocol based on the compatibility matrix.
[5 marks]

(c) Define “deadlock” and give an example.


[4 marks]

(d) Explain how a deadlock state can be detected and how the system can break such a state.
[7 marks]

QUESTION 11

Consider the following relational schema that correspond to a part of the database
for a computer training college, which offers a variety of IT courses:
STUDENT(S#, S_Name, S_DOB, S_Address)
COURSE(C#, C_Name, StartDate, EndDate, Fee, D#)
DEPARTMENT(D#, D_Name, D_Location)
GRADE(S#, C#, Grade, Date_of_Grade)
The following assumption are made with regard to the size of each relation:
 The STUDENT relation contains 1000 records
 The COURSE relation contains 100 records
 The DEPARTMENT relation contains 10 records
 The GRADE relation contains 5000 records
 There are no more than 50 students in any one course
 It is possible to hold up to 50 records for an intermediate relation in the main
memory.

8
(a) Discuss the objective of query optimisation in a database system, and briefly
describe various stages involved in the query optimisation process.
[8 Marks]

(b) Formulate the following query using correct SQL syntax:


Find the names and numbers of all the students who have attended the
course entitled ‘E-Commerce’
[2 Marks]

(c) Provide two possible options to evaluate the above query. Express each of
these options in relational algebra and clearly show all the steps required in
the evaluation of the query.
[4 Marks]
(d) For each of the options identified in (c) above, calculate the number of total
tuple input/output operations required for each step. Recommend the best
options based on the results
[11 Marks]

Note on Question 11 (d)


1. Students are asked to work out the total I/O required for each step, NOT the
size of intermediate relations.
2. No marks should be awarded if the student only gives the numbers for the
intermediate relations without specifying tuple I/O numbers.
3. Students may choose different options (from those given above) to evaluate
the query.

Вам также может понравиться