0% found this document useful (0 votes)
11 views4 pages

Final EST Solution

The document discusses solutions to various database management system concepts including: 1) Finding the minimal cover of functional dependencies from a given set. 2) Explaining the two phase locking protocol for concurrency control and how it prevents dirty reads and cascading rollbacks. 3) Defining database concurrency problems like lost updates, dirty reads, and incorrect summaries and providing examples. Additionally, discussing schedule serializability for transactions. 4) Creating a PL/SQL function to return employee salary and calling the function. As well as discussing anomalies in data modification and providing examples. 5) Using a cursor to loop through employee records, update fields, and call a procedure to pass a parameter. Additionally

Uploaded by

Shubham Thakur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views4 pages

Final EST Solution

The document discusses solutions to various database management system concepts including: 1) Finding the minimal cover of functional dependencies from a given set. 2) Explaining the two phase locking protocol for concurrency control and how it prevents dirty reads and cascading rollbacks. 3) Defining database concurrency problems like lost updates, dirty reads, and incorrect summaries and providing examples. Additionally, discussing schedule serializability for transactions. 4) Creating a PL/SQL function to return employee salary and calling the function. As well as discussing anomalies in data modification and providing examples. 5) Using a cursor to loop through employee records, update fields, and call a procedure to pass a parameter. Additionally

Uploaded by

Shubham Thakur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Solution of EST

1a
1(b) {B→D, BD→E, F→J, F→B, F→E}

{B→D, BD→E, F→J, F→B}


Redundant FD : {F→E}

{BD→E}
{B}+ = {B,D}
D is extra and is removed.
{B→E}

Minimal Cover = {B→D, B→E, F→J, F→B}

2(a) It is a method of concurrency control in DBMS that ensures serializability by applying a lock
to the transaction data which blocks other transactions to access the same data simultaneously.
Two Phase Locking protocol helps to eliminate the concurrency problem in DBMS.
• This locking protocol divides the execution phase of a transaction into three different
parts.
• In the first phase, when the transaction begins to execute, it requires permission for
the locks it needs.
• The second part is where the transaction obtains all the locks. When a transaction
releases its first lock, the third phase starts.
• In this third phase, the transaction cannot demand any new locks. Instead, it only
releases the acquired locks. [2
Marks]
because of Dirty Read in T2 and T3 in lines 8 and 12 respectively, when T1 failed we have to
roll back others also. Hence, Cascading Rollbacks are possible in 2-PL.

2 marks
2(b) 1 mark for each =1x3=3
i) ii) iii)

3(a) Concurrency definition 0.5 marks and


Lost update, Dirty Read, Incorrect Summary
3*1.5 = 1 marks for each problem definition and 0.5 for each example.

3(b) 2 marks 1 for each


Given in question Solution
Schedule S1 S1 :
T1 T2 T1 T2
--------------------- r1(x)
r1(X) r1(y)
r1(Y) r2(x)
r2(X) w1(x)
r2(Y) r2(y)
w2(Y) w2(y)
w1(X)

S1 is not conflict serializable but S2 is conflict serializable as we can convert it to serial


schedule T2->T1 (Swapping the non conflict pairs)

Schedule S2 S2:
T1 T2 T1 T2
--------------------- r2(x)
r1(X) r2(y)
r2(X) w2(y)
r2(Y) r1(x)
w2(Y) r1(y)
r1(Y) w1(x)
w1(X)

A(A create or replace function c_sal(Ecode number) return number


) as (1 marks , -0.5 for return)

S1 emp.salary%type;
Begin
Select salary into S1 from emp where emp_id=Ecode;
return S1; (1 marks, -0.5 for return )
exception
When No_Data_Found then (1 marks)
return -1; (-0.5)
End c_sal;
Declare (1 mark)
eid number(4);
Sal number(10,4);
begin
eid:=&entereid;
Sal:=calc_sal(eid); or Sal:= calc_sal(23);
Dbms_output.put_line('salary of an employee '||Sal);
end;
Note: -0.5 for nesting function for local function block
4(b) Three Anomalies Insert delete and update with examples (3x1(0.5 for
example+0.5 for explanation)
5(a)
DECLARE
v_emp_rec emp%ROWTYPE;

id emp.emp_id%type;

CURSOR cur_emp_name(empno number) IS

SELECT *
FROM emp where emp_id not in empno;

procedure p1(id number) is


BEGIN

OPEN cur_emp_name(id);

LOOP

FETCH cur_emp_name INTO v_emp_rec;

exit WHEN cur_emp_name%NOTFOUND;


v_emp_rec.da:=0.5*v_emp_rec.bp;

v_emp_rec.hra:=0.2*v_emp_rec.bp;

update emp set da=v_emp_rec.da, hra= v_emp_rec.hra


where emp_id=v_emp_rec.emp_id;

v_emp_rec.total:=v_emp_rec.bp+v_emp_rec.da+v_emp_rec.hra;
update emp set total=v_emp_rec.total

where emp_id=v_emp_rec.emp_id;
END LOOP;

CLOSE cur_emp_name;

END;

BEGIN
id:=&id;

p1(id);

END;

1 mark for declaration of parameterized cursor with appropriate SQL statement. 1


mark for definition of procedure. 1 mark for open the parameterized cursor with
fetching records. 1 mark for updating the records in employee table. 1 mark for
calling the procedure by passing the id as the parameter.

5(b) CREATE OR REPLACE TRIGGER commisioned_trig

before INSERT ON emp (1 marks)


FOR EACH ROW
BEGIN

IF:new.dept = 'CS' THEN (0.5)


:NEW.commision := :NEW.salary * .5; (it can be any value) (0.5)

( select statement is also considered 0.5 marks given )

END IF;
END;

You might also like