You are on page 1of 7

Type: MCQ

Q1. Consider the relation instance given and determine whether AB→C,C→B holds?

(0.5)

1. ** NO,YES
2. YES,YES
3. YES,NO
4. NO,NO

Q2. How relation schema is created for a multivalued attribute 'A' in Entity E1 having 1-M
relationship with Entity E2? (0.5)

1. Primary Key(E1) ∪ Primary Key(E2)


2. ** Primary Key(E1) ∪ A
3. Primary Key(E1) - Foreign Key(E1) ∩ A
4. Primary Key(E1) ∪ Foreign Key(E1) – A

Q3. Consider the relation Telephone (CustId, STD_Code, City, STD_Region) and Set of
functional dependencies
F= {CustId → STD_Code, STD_Code →City, STD_Code→ STD_Region}.
What is the closure of STD_Code? (0.5)

1. {CustId, STD_Code, City, STD_Region}


2. {STD_Code, City}
3. {CustId, STD_Code, City}
4. ** {STD_Code, City, STD_Region}

Q4. Consider the relation R (A, B, C, D, E) , functional dependence F={ABC→ABCDE,


AC→ABCDE, AB→ABCDE, A→ABD, B→ABCDE C→BCD} and following statements-
(i). ABC is candidate key
(ii). AC is minimal super key
(iii). AB is Super key only
(iv). AB is minimal Super key
Select the correct option given below. (0.5)

1. ** (ii) and (iii) TRUE


2. (i) and (ii) TRUE
3. (i) and (iii) TRUE
4. (ii) and (iv) TRUE

Q5 Which of the following statements are true about PL/SQL stored procedures?
(i). The default mode of parameter passing is IN
(ii). Values passed as parameters to a procedure as arguments in a calling statement are
termed formal parameters.
(iii). The parameters in a procedure declaration are called actual parameters
(iv). If a procedure raises an exception, the formal parameter values are not copied back to
their corresponding actual parameters

(0.5)

1. (ii) and (iii)


2. (i) and (iii)
3. ** (i) and (iv)
4. (ii) and (iv)

Q6. Which of the following is a trivial functional dependency for R=(A,B,C)?

(0.5)

1. ** ABC→AB
2. A→B
3. BC→BA
4. B→C
Q7. In the relation EMP(EmpNo,Ename,Salary,DeptNo), (Empno,Name) → Deptno , but DeptNo is
only dependent on EmpNo.Such functional dependency is known as__________ dependency.

(0.5)

1. ** Partial

2. Fully Functional

3. Transitive

4. Formal
Q8. How many relation schemas can be formed from the below ER Diagram:

(0.5)

1. ** 7

2. 6
3. 5

4. 8

Q9. An implicit cursor has attributes that return information about the most recently run
________ statement that is not associated with a named cursor. (0.5)

1. ** SELECT

2. CREATE

3. DROP

4. ALTER
Q10. The output of SELECT LAST_DAY('12/05/2022') FROM DUAL is; (0.5)

1. ** Error

2. 31-MAY-22

3. 31-05-22

4. 30-MAY-22

Type: DES

Q11. Consider the following requirements and design an ER model correspondingly.


Assume that students of an institute MMM are organizing a technical fest. The fest has 10 diffe re nt
events such as - Debug the Code, Project Presentation, Add Innovative feature to a Product etc. Each
event is identified by unique ID, Name of event, Date_of_event, No_Rounds. We need to store
information about all students such as – Regno, Name, Phone, Branch. Any two students can
manage exactly one event only. Each event is managed by two students only. We also need to store
information about participants such as – a unique Part_id, Name, Phone. Each event can have
maximum 5 participants and a participant can participate in maximum of 2 events only. (2)
ANS
Q12. Consider the tables given in the Question 14. Write a stored function to retrieve total number
of leave applied between 01-01-2022 to 21-12-2022 depending on Type of leave, empno entered by
the user. (2)
ANS
CREATE OR REPLACE FUNCTION Q2_Fun(eno in emp_leaves.empno%type,
lev_typ leaves_applied.leave_type%type) RETURN NUMBER IS
TOT_LEVS NUMBER:=0;

CURSOR leave_cnt IS SELECT end_date - from_date num_days from LEAVES_APPLIED WHERE


leave_type=lev_typ AND EMPNO=ENO AND FROM_DATE>='01-JAN-2022' AND FROM_DATE<='31-
DEC-2022';

BEGIN
FOR L in leave_cnt
LOOP
TOT_LEVS:=TOT_LEVS+L.num_days;
END LOOP;
return TOT_LEVS;
end;
/
OR
CREATE OR REPLACE FUNCTION q2_Fun_1(eno in emp_leaves.empno%type,
lev_typ leaves_applied.leave_type%type) RETURN NUMBER IS
TOT_LEVS NUMBER:=0;
BEGIN
select SUM(end_date-from_date) INTO TOT_LEVS from LEAVES_APPLIED WHERE
leave_type=lev_typ
AND EMPNO=ENO AND FROM_DATE>='01-JAN-2022' AND FROM_DATE<='31-DEC-2022';
return TOT_LEVS;
END;
/
Q13. Consider the following relational schema and functional dependency set and find the closure of
BC. (with detailed steps).
R (A, B, C, D, E, F, G, H) and F= {A→BC, BC→D, G→A, D→F, C→G, H→E} . (3)
ANS
Q14. Write a trigger EMP_LEAVE_TRG considering the following tables containing information about
-employees, their leaves available and applied leaves.

EMP_LEAVES stores information about- per year, for each employee how many numbers of leave
available for each kind of leaves (Casual Leave-CL & Compensatory Leaves-CPL).
EMP_LEAVES (Empno, No_of_CL_in_Balance, No_of_CPL_ in_Balance)
LEAVES_APPLIED stores information about which employee applied which leave and when.
Leave_Type is CL or CPL; Approval is Y or N.
LEAVES_APPLIED (Leave_Appl_ID, Empno, Leave_Type, From_date, End-date, Approval)
Empno is foreign key referencing LEAVES_APPLIED

The trigger EMP_LEAVE_TRG must be fired when an employee applies for leave (with Approval value
N). Trigger should allow to insert record if number of leaves in balance of specified leave type is
more than or equal to number of leaves applied otherwise reject the insertion.

If inserted, display-

Request sent to Superior for Approval.

Otherwise,

No enough leaves in balance.. (3)

Ans:
CREATE OR REPLACE TRIGGER Q4_TRG BEFORE INSERT ON LEAVES_APPLIED FOR EACH ROW
DECLARE
NO_DAYS NUMBER(2);
CL1 NUMBER(2);
CPL1 NUMBER(2);
BEGIN
SELECT No_of_CL_in_Balance, No_of_CPL_in_Balance INTO CL1, CPL1 FROM EMP_LEAVES
WHERE EMPNO=:NEW.EMPNO;
IF :NEW.LEAVE_TYPE='CL' THEN
IF NO_DAYS<=CL1 THEN
DBMS_OUTPUT.PUT_LINE(' INSERTED- '||NO_DAYS||'-CL Request sent to Superior for Approval.');
ELSE
RAISE_APPLICATION_ERROR(-20001,' NOT ENOUGH CL LEAVES ');
END IF;
ELSIF :NEW.LEAVE_TYPE='CPL' THEN
IF NO_DAYS<=CPL1 THEN
DBMS_OUTPUT.PUT_LINE (' INSERTED- '||NO_DAYS||'-CPL Request sent to Superior for Approval.');
ELSE
RAISE_APPLICATION_ERROR (-20002,' NOT ENOUGH CPL LEAVES ');
END IF;
ELSE
DBMS_OUTPUT.PUT_LINE (' SOME ERROR ');
END IF;
END;
/

You might also like