Unity University
Computer Science Department
Worksheet on Database Management
I) Identify each of the following schedule as:
Serial/Non-serial
Serializable/ Non-serializable
Conflict serializable/ View serializable
Recoverable/ Non-Recoverable
Cascading/ Cascadeless/ Strict
Schedule S1 Schedule S2
T1 T2 T3 T1 T2 T3
Read1(D) … … … Write2(D) …
… Write2(D) … Read1(D) … …
Write1(D) … … … … Write3(D)
… … Write3(D) Write1(D) … …
commit … … … commit …
… commit … … … commit
… … commit commit … …
Schedule S3 Schedule S4
T1 T2 T3 T1 T2 T3
… Write2(D) … Read1(D) … …
Read1(D) … … Write1(D) … …
… commit … commit … …
Write1(D) … … … Write2(D) …
commit … … … … Write3(D)
… … Write3(D) … … commit
… … commit … commit …
Page 1 of 6
Schedule S5 Schedule S6
T1 T2 T3 T1 T2 T3
Read1(D) … … Read2(C) …
Write1(D) … … Read1(D) … …
Read2(D) … Write1(D) … …
… Read2(C) … … Write3(D)
Write2(C) Read2(D) …
… Read3(D) … Write2(C) …
… … Read3(C) … … Read3(C)
Write3(C) Read1(C) … …
commit … commit …
Read1(C) Write1(C) … …
Write1(C) … … … Write3(C)
… commit commit … …
commit … … commit
II) Given the following schema of a database along with the relationships between the
relations:
Page 2 of 6
Convert the following TSQL statements into relational algebra expression.
o SELECT * FROM department WHERE dep_code IN
(SELECT student.department FROM student WHERE division LIKE ‘regular’)
o SELECT * FROM department WHERE dep_code IN
(SELECT student.department FROM student WHERE division LIKE ‘ext%’ OR division LIKE ‘week%’)
o SELECT title,faculty FROM department WHERE dep_code IN
(SELECT student.department FROM student WHERE division LIKE ‘regular’)
o SELECT title,faculty FROM department WHERE dep_code NOT IN
(SELECT student.department FROM student WHERE division LIKE ‘regular’)
o SELECT title,id,gender FROM department JOIN student ON dep_code=student.department
WHERE dep_code IN
(SELECT student.department FROM student WHERE division LIKE ‘regular’)
o SELECT title,id,gender FROM department JOIN student ON dep_code=student.department
WHERE id NOT IN
(SELECT st_id FROM enrollment)
Write SQL statements to extract each of the following information and then convert each SQL
statement into the corresponding relational algebra expression.
o Extract id, fname, lname, and division of non-regular students.
o Extract id and names of students that have scored an ‘A’ if male OR that have scored ‘B’ if
female.
o Extract id and names of female students that have never scored an ‘F’.
o Extract course titles and credit hours of those courses that no student is registered for. What if
only those courses that are offered by computer science department?
o Extract id, fname, lname, and division of all students that have never scored an ‘F’. What if those
that have never scored an ‘F’ in main courses? And what if those that belong to computer science
department?
Try to find equivalent algebraic expressions for each of the expressions you wrote for the above
questions.
Build query trees for each of the relational algebra expressions you formed above. Which of the
query trees you think is optimal and why?
What do the following query trees do? Write sql statements for each.
∏ id,fname STUDENT
Page 3 of 6
A) ∏
id,fname
division=’regular’ gender=’male’
STUDENT STUDENT
B)
∏
id,fname
id=id
division=’regular’ gender=’male’
STUDENT STUDENT
C) ∏
id,fname
Page 4 of 6
division=’regular’ gender=’male’
STUDENT STUDENT
∏
D) id,fname
division=’regular’ ∏
id,fname,mname,lname,division,department, gender
STUDENT grade=’F’
id = st_id
STUDENT ENROLLMENT
III) Explain the following terms:
Pipelining Query tree Optimization
Materialization Optimal evaluation plan Query processing
Page 5 of 6
Relational algebra Lost update problem Secondary key
Serial schedule Uncommitted update candidate key
Serialization problem Attribute domain
Schedule Transaction Integrity constraint
Serializable schedule Archival log Object privilege
Conflict equivalence Normal log System privilege
View equivalence Compensation Distributed database
transaction
Result equivalence Homogeneous
Tuple distributed database
Recoverable schedule
Relation Heterogeneous
Cascadeless recoverable
schedule Relation schema distributed database
Strict recoverable Relation instance Replicated relation
schedule key Full replication
Non-recoverable super key Fragmented relation
schedule Primary key Fully redundant
Concurrency control
IV) Explain the three main integrity constraints:
Key constraint
Domain constraint
Referential integrity constraint
V) What are the advantages and disadvantages of relation replication and
fragmentation?
Page 6 of 6