Numerical Questions
Numerical Questions
SERIALIZABILITY
[UNIT 4]
Problem 1. Check whether the given schedule S is view serializable or not.
Solution-
We know, if a schedule is conflict serializable, then it is surely view serializable. So, let us
check whether the given schedule is conflict serializable or not.
Clearly, there exists a cycle in the precedence graph. Therefore, the given schedule S is not
conflict serializable.
Now,
• Since, the given schedule S is not conflict serializable, so, it may or may not be view
serializable.
• To check whether S is view serializable or not, let us use another method.
• Let us check for blind writes.
Checking for Blind Writes-
• There exists no blind write in the given schedule S.
• Therefore, it is surely not view serializable.
Problem-03: Check whether the given schedule S is view serializable or not.
If yes, then give the serial schedule.
S : R1(A) , W2(A) , R3(A) , W1(A) , W3(A)
Solution- For simplicity and better understanding, we can represent the given schedule
pictorially as-
We know, if a schedule is conflict serializable, then it is surely view serializable. So, let us
check whether the given schedule is conflict serializable or not.
Checking Whether S is Conflict Serializable Or Not-
Step-01: List all the conflicting operations and determine the dependency between the
transactions-
Clearly, there exists a cycle in the precedence graph. Therefore, the given schedule S is not
conflict serializable. Since, the given schedule S is not conflict serializable, so, it may or may
not be view serializable.
To check whether S is view serializable or not, let us use another method. Let us check for
blind writes.
Checking for Blind Writes-
There exists a blind write W2 (A) in the given schedule S. Therefore, the given schedule S
may or may not be view serializable.
To check whether S is view serializable or not, let us use another method. Let us derive the
dependencies and then draw a dependency graph.
SOLUTON-
a) SELECT * from EMPLOYEE;
b) SELECT * from EMPLOYEE WHERE age = 20 AND city = ‘London’;
c) SELECT employeename from EMPLOYEE WHERE employeename
LIKE ‘r%’;
Problem 3. Write SQL statements for following:
Student (Enrno, name, courseId)
Course (courseId, coursename, duration)
a. Create student and course tables.
b. Insert 3 records in both student and course table.
c. Add column named city in student table.
d. Rename column named city to country in student table.
SOLUTON-
a) CREATE TABLE Student
(Enrno int (3), name varchar (20), courseId varchar (10)
);
Solution
i. age > 45(Actor)
Retrieves details of all actors above the age of 45. The output table is as
follows:
v. year<2000(Film) Ո year<2010(Film)
Retrieves details of all films released between 2000 and 2010. The output table
is as follows:
For each of the following questions, formulate the specified queries in tuple-
relational calculus and as a computation in relational algebra.
a) Retrieve details of all films that were released in 2010. The output schema
should be the same as that of the Film table.
b) Retrieve details of all actors that are not in their thirties. The output schema
should be the same as that of the Actor table.
c) Retrieve the names of all directors.
d) Retrieve the names of all American directors.
e) Find out the names of all British actors above the age of 40.
Solution –
a) Retrieve details of all films that were released in 2010. The output schema
should be the same as that of the Film table.
year<2000(Film)
b) Retrieve details of all actors that are not in their thirties. The output schema
should be the same as that of the Film table.
(age<30) U (age>39) (Actor)
or
age<30(Actor) U year>39(Actor)
c) Retrieve the names of all directors.
title (Film)