CSCI 453 - Computer Science and Engineering Department

The American University in Cairo
Computer Science Department
CSCI 453
Dr. KHALIL
EXAM - I
Last Name : ...........................................................
Spring 2005
ID: ...................................
First Name: ...........................................................
Solve only 4 questions
Do not turn this page until asked to do so.
*
Exam time is 50 minutes.
*
Put the answers on the same question sheet, do not use any additional papers, even for scratch.
*
Write your name, ID, section no. in the indicated places.
*
Read the exam instructions.
*
Read the honesty policy.
*
Sign the following statement.
HONESTY POLICY
Cheating in Exams is a violation of the honesty policy of AUC. Whispering, talking, looking at
someone else’s paper, or copying from any source is considered cheating. Any one who does any
of these actions or her/his answers indicates that she/he did any of them, will receive a punishment
ranging from zero in this exam to failing the course. If repeated, it may lead to dismissal from
AUC.
I have read the honesty policy and exam instructions and I am presenting this
exam as entirely my effort.
Signature: _______________
--------------------------------------------------------------------------------------------------------------------------DO NOT USE THIS SECTION
Question
Points
25
25
25
25
Total
100
1
Grade
QUESTION 1 ( 25 points)
Some of the following statements are completely correct while others are partially correct (only part of it that is
incorrect). Mark those statements that are correct and try to correct those that are partially correct.
1. In distributed databases, there is a serious problem with distributed recovery which is the distributed commit.
When a transaction is updating data at several sites, it cannot commit until it is sure that the effect of the
transaction on every site cannot be lost. This means that every site must first have recorded the local effects of the
transactions permanently in the local site log on disk. The Basic 2PL commit protocol is often used to ensure the
correctness of distributed commit.
....................................................................................................................................................................................................................
....................................................................................................................................................................................................................
....................................................................................................................................................................................................................
2.
The ACID properties of a transaction are Atomicity, Correctioness, Isolation, and Durability.
....................................................................................................................................................................................................................
....................................................................................................................................................................................................................
....................................................................................................................................................................................................................
3.
Heuristic query optimization depends on the semantics and not the syntax of the database. It is based only on the
general qualities of the relational algebra expressions and involves substituting relational algebra expressions with
more efficient expressions using equivalence preserving transformation rules.
....................................................................................................................................................................................................................
....................................................................................................................................................................................................................
....................................................................................................................................................................................................................
4.
Web database gateways link stateless systems (i.e., databases) with a stateful, connectionless protocol (i.e., HTTP).
In other words, a Web database gateway (middleware)is a bridge between the Web and a DBMS, and its objective
is to provide a Web-based application the ability to manipulate data stored in the database.
....................................................................................................................................................................................................................
....................................................................................................................................................................................................................
....................................................................................................................................................................................................................
5.
The basic 2PL protocol requires every transaction lock all the items it needs in advance; if any of the items cannot be
obtained, none of the items are locked. This solution obviously limits concurrency.
....................................................................................................................................................................................................................
....................................................................................................................................................................................................................
....................................................................................................................................................................................................................
6.
In distributed database environment, copy transparency means that the system supports the optional existence of
multiple copies of database objects while location transparency means that a user can submit a query that accesses
distributed objects without having to know where objects are.
....................................................................................................................................................................................................................
....................................................................................................................................................................................................................
....................................................................................................................................................................................................................
7. Replication is useful in improving the query processing and optimization.
....................................................................................................................................................................................................................
....................................................................................................................................................................................................................
....................................................................................................................................................................................................................
8.
In general, a fragment of relation R can be specified by a SELECT-PROJECT
L(C(R)).
If C = True and L <> ATTRS(R), we get a mixed fragment
If C <> True and L = ATTRS(R), we get a vertical fragment.
If C <> True and L <> ATTRS(R), we get a horizontal fragment.
A relation can itself be considered a fragment with C=True and L= ATTRS(R).
combination of operations
....................................................................................................................................................................................................................
....................................................................................................................................................................................................................
....................................................................................................................................................................................................................
9.
For large databases, the communication cost is the one considered in the systematic optimization of query processing,
while for distributed databases, the main emphasis is on the computation cost.
....................................................................................................................................................................................................................
....................................................................................................................................................................................................................
....................................................................................................................................................................................................................
10. In distributed databases with No Local Autonomy, direct access by local transactions to a server is permitted. Such
type of DDBMS is called fragmented DDBMS (or a multidatabase system). In such a system, each server is an
independent and autonomous centralized DBMS that has its own local users. Each server can authorize access to
particular portions of its database by specifying an export schema, which specifies the part of the database that may
be accessed by a certain class of nonlocal users.
....................................................................................................................................................................................................................
....................................................................................................................................................................................................................
....................................................................................................................................................................................................................
2
QUESTION 2 ( 25 points)
Consider the following relational schema for a bank.
BRANCH (BranchName, Location, Manager)
CUSTOMER (AccountNo, CustomerName, BranchName, Balance)
TRANSACTION (TransactionNo, AccountNo, Tdate, Ttype, Tvalue)
The bank consists of one main branch and several other branches. There is a computer site for each branch. In the site of
the main branch, it is required to maintain the data of all customers (and their transactions) of that branch besides data
about all customers (and their transactions) of all other branches having a balance that exceeds LE 1,000,000. In the
computer site of each other branch, it is required to maintain all information about only the customers and transactions
of that branch.
a)
Design a distributed database over the different sites according to the given requirements (write a SQL query
that will produce each required fragment in each computer site). You can refer to the main branch as “Main”
and to any other branch as “BranchX”.
b) Determine the type and replication level of each resulting fragment.
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
3
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
4
QUESTION 3 ( 25 points)
a) In Web applications, there are two main general approaches for the server-side solutions: the CGI (Common
Gateway Interface) and the APIs (Application Programming Interface). An API or CGI works as a Web server
interface to the web-to-database middleware. Name on the following scheme the different entities and
interfaces of a typical web system.
b) Give the technical comparison between the CGI approach and the API approach regarding the given technical
issues:
Features
CGI
Language-independent
Runs in different process from
core Web server
Open standard
Web server architectureindependent
Supports distributed computing
Multiple, extensible roles
Memory sharing with other
processes
Does NOT create new process
for each instance
Easy to use
5
APIs
QUESTION 4 ( 25 points)
. Consider the given relational database schema for a university application. The primary key of each relation is underlined.
STUDENT (StudentNumber, Name, Class)
DEPARTMENT (DeptCode, DeptName)
MAJOR (StudentNumber, MajorDeptCode)
MINOR (StudentNumber, MinorDeptCode)
INSTRUCTOR (InstNum, Name, Status, DeptCode)
COURSE (DeptCode, CourseNumber, CourseName, CreditHours)
PREREQUISITE (DeptCode, CourseNumber, PreDeptCode, PreCourseNumber)
SECTION (DeptCode, CourseNumber, SectionIdentifier, Semester, Year, InstNum)
TRANSCRIPT(StudentNumber, DeptCode, CourseNumber, SectionIdentifier, Semester, Year,
Grade)
Put the following queries in more efficient expressions:
1.
(((((STUDENT join MAJOR) join DEPARTMENT) W here CLASS=”Junior”)[Name, DeptName]) W here
DeptName=”Computer Science”)
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
2.
((STUDENT join TRANSCRIPT) W here DeptCode=”CSCI”)[StudentNumber, Name]
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
3.
((((((STUDENT join TRANSCRIPT) W here DeptCode=”CSCI”) W here CourseNumber=453) W here
Semester=”Spring”) W here Year=2004)[StudentNumber, Name, SectionIdentifier, Grade])[Name, Grade]
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
4.
(STUDENT join MAJOR) [StudentNumber]
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
6
QUESTION 5 ( 25 points)
A DBMS attempts run the following schedule:
T1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
T2
Read_lock(Y)
Read_item(Y)
Y := Y * 2
Write_lock(Y)
Write_item(Y)
Read_lock(X)
Read_item(X)
X=X+Y
Read_lock(Y)
Read_item(Y)
Read_lock(X)
Read_item(X)
X=X+Y
Write_lock(X)
Write_item(X)
Unlock(X)
Unlock(Y)
Write_lock(X)
Write_item(X)
Unlock(X)
Unlock(Y)
N.B. It would be useful and saving time to refer to line numbers to clarify your answer.
1. Draw a wait-for-graph. How can you tell that deadlock has occurred?
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
7
2. Write down the wait-die protocol and redo the same schedule using the wait-die scheme.
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
8
3. Write down the wound-wait protocol and redo the same schedule using the wound-wait
scheme.
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
9
QUESTION 6 ( 25 points)
a. A schedule S is said to be conflict serializable if it is conflict equivalent to some serial schedule S’. Check the
serializability of the following schedule. If the schedule is serializable, determine its equivalent serial schedule.
Sc: r3(Z); r3(Y); w3(Y); r1(Y); r1(Z); r2(X); w2(X); w1(Y);w1(Z); r3(X);
r2(Y);w2(Y);w3(x);
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
......................................................................................................................................................................................................................
b. A DBMS is a complex software system. The following diagram shows a simplified structure of a typical DBMS.
Name on the diagram every component, interface, and users involved in such system.
10