Dbms Solved Paper
Dbms Solved Paper
KTU STUDENTS
DDL (data definition language) is used to describe the structures that hold data in the
database; DML (data manipulation language) is used to express query and update
operations on the data stored in the database.
A sample DDL statement like CREATE TABLE (...), ALTER TABLE …, DROP TABLE
with sample table names, attribute names etc. Correct syntax need not be insisted
completely. 1 mark
A sample DML statement like SELECT…, INSERT…, DELETE… etc. with some sample
table names, attribute names etc. Correct syntax need not be insisted completely.
1 mark
3. Can we represent the situation modelled by the following ER diagram without the relationship (3)
‘HAS’? If so, draw the new diagram. If not, give the reasons. (Entities are DEPARTMENT and
EMPLOYEE. Attibutes names are given under entity names; keys are underlined.)
DEPTCODE
KTU
∏A,B (B=3( A = 2 (R))) STUDENTS
can be commuted. Some of the equivalent expressions are,
∏A,B ( A = 2 (B=3 (R)))
4 marks
Some students may also answer as single expression using the relation-
rename-operator, ρ (as followed in Korth et.al.), and can be given full
credit.
Equivalent expressions that give correct answers can be given marks.
6. A company has the following scenario: There are a set of salespersons. Some of them manage other (9)
salespersons. However, a salesperson cannot have more than one manager. A salesperson can be an
agent for many customers. A customer is managed by exactly one salesperson. A customer can place
any number of orders. An order can be placed by exactly one customer. Each order lists one or more
items. An item may be listed in many orders. An item is assembled from different parts and parts
KTU (i)
(ii)
STUDENTS
can be common for many items. One or more employees assemble an item from parts. A supplier can
supply different parts in certain quantities. A part may be supplied by different suppliers.
Identify and list entities, suitable attributes, primary keys, foreign keys and
relationships to represent the scenario.
Draw an ER diagram to model the scenario using min-max notation.
KTU STUDENTS
KTU
7.
STUDENTS
a. Justify the importance of weak entity sets with the help of an example.
A diagram showing a weak entity set, identifying relationship and owner entity set is
(3)
expected. In addition an explanation on why weak entity set is important in the given
situation also has to be given.
Sample:
The ER diagram represents payment made against each loan. As different loans can have
the same payment number (i.e. instalment number), ‘Payment No.’ cannot be a key of the
‘Payment’ entity set and hence it is weak entity set connected to the strong entity set
‘Loan’. Diagram : 1.5 marks
Explanation: 1.5 marks
b. In the ER diagram below, names of entity sets and relationships are shown in capital and (6)
corresponding attributes are listed under each such name. Key attributes are underlined. All the
participations are total. Use the standard synthesis procedure to convert the ER diagram into the
corresponding relational schema. Clearly show primary and foreign keys.
5
KTU STUDENTS
(here primary keys are underlined; foreign keys are double underlined)
Full marks only if all the tables are shown with all the required attributes and if the foreign
and primary keys are clearly mentioned.
PART C
Answer all questions
8. Illustrate the GROUP BY clause with the help of a real example. (3)
One/two sentence explanation of GROUPBY 1 mark
A sample table, Correct SQL expression with GROUP BY and output 2 marks
Note that the attributes appearing in GROUP BY clause should appear in SELECT clause
also.
9. Consider the query SELECT NAME, AGE FROM STUDENT WHERE GENDER = ‘Male’ on the (3)
table STUDENT(ROLLNO, NAME, AGE, GENDER, ADDRESS). Give a relational algebra
expression corresponding to the query. Is result produced by the query and your expression always
the same? Why?
6
10. Determine any two candidate keys of the relation R(A,B,C,D,E,F) with FDs AB→C,C→AD,
AB (3)
D→EF, F→B.
Determining each key 1.5 marks
To determine the keys, student can use the standard algorithm to compute X+; alterntively,
he/she can use Amstrongs Axioms
Axioms.. The steps should be shown for giving full marks.
marks
AB and C are the two obivious keys. But students may come up with other keys through
Armstrong’ Axioms.. Make sure that they are minimal super keys before aawa
warding marks.
11. Give an example for a relation that has insertion, deletion and update anomalies. Which type(s) of (3)
functional dependency can formally model these anomalies? Quote one such dependency from your
example
Any relation which is a result of combining two real-world
world entity sets will have these
anomalies.
The student us expected to
Give one such relation. For example, STUDENT
STUDENT-COURSE(ROLLNO,
ROLLNO, COURSEID,
COURSEID
KTU
STUDENTS
NAME, CLASS, CNAME, CCREDIT, GRADE).
1 mark
Two types of the dependencies that model it – transitive dependency and partial
functional dependency. 1mark
Quote any one of PFD or TFD from the given relation. (Example: {ROLLNO,
COURSEID } → CNAME while COURSEID → CNAME is PFD) 1 mark
PART D
Answer any two full questions
12. a. Illustrate the use of assertions with a typical example. (3)
The above assertion makes sure that salary of an employee does not exceed that of his/her
7
b. Consider a relation (A,B,C,D,E,F) with A as the only key. Assume that the dependencies E→F and (6)
C→DEH hold on R.
(i) Is R is in 2NF? If not, decompose to 2NF.
(ii) Is R is in 3NF? If not, decompose to 3NF.
(Here the attribute H is missing. However that does not affect the approach to
answer the question. The presence of H is quite irrelevant as it does not appear
on the left side of any FD. C→DEH and be taken as C→DE.)
(i) There is no partial functional dependency as the only key is not composite.
Hence the relation in 2NF. 2marks
(ii) There are two transitive dependencies – through E→F and through C→DE.
Therefore decompose the original relation into,
1. R1(A,B,C,E)
2. R2(C,D,E)
3. R3(E,F)
Primary keys underlined; foreign keys double-underlined.
KTU
13.
STUDENTS
Complete decomposition and a description similar to the above: 4 marks
In the following tables ADVISOR and TAUGHTBY are foreign keys referring to the table
PROFESSOR. ROLLNO and COURSEID in ENROLLMENT refer to tables with primary keys of
the same name.
STUDENT(ROLLNO, NAME, AGE, GENDER, ADDRESS, ADVISOR)
(9)
Each of the above queries can be expressed in multiple ways in SQL. All syntactically and
semantically correct expressions can be awarded marks. The most efficient ones are shown
below:
(i) SELECT C.CNAME FROM PROFESSOR P, COURSE C WHERE P.PROFID =
C.TAUGHTBY AND P.PNAME = ‘Prof. Raju’ 2 marks
(ii) Being a negation query, the best way to express is through nested query.
SELECT S.NAME FROM STUDENT S WHERE S.ROLLNO NOT IN (SELECT
E.ROLLNO FROM ENROLLMENT E, COURSE C, PROFESSOR P WHERE
E.COURSEID=C.COURSEID AND C.TAUGHTBY = P.PROFID AND
P.PNAME = ‘Prof. Ganapathy’)
8
14. Assume that the relation R(P,Q,S,T,U) with FDs P → S, Q → S, S → T, TU → S, SU → Pis (9)
decomposed into 5 relations: R1(P,T), R2(P,Q), R(Q,U), R4(S,T,U) and R5(P,U). Apply the
KTU STUDENTS
standard algorithm to test if the decomposition isalossless-join decomposition.
The student is expected to start with an initial table similar to the one below and show the
status after applying each FD. (Note:- There are can be many matrix sequences, depending
on the order in which the dependencies are applied. Some of them will take more number
of iterations to converge and some less. The sequence when the FDs are applied in the
given order is shown below.)
Initial table:
P Q S T U
R1 a1 b12 b13 a4 b15
R2 a1 a2 b23 b24 b25
R b31 a2 b33 b34 a5
R4 b41 b42 a3 a4 a5
R5 a1 b52 b53 b54 a5
P→S
P Q S T U
R1 a1 b12 b13 a4 b15
R2 a1 a2 b23 b13 b24 b25
R b31 a2 b33 b34 a5
R4 b41 b42 a3 a4 a5
R5 a1 b52 b53 b13 b54 a5
S→T
P Q S T U
R1 a1 b12 b13 a4 b15
R2 a1 a2 b23 b13 b24a4 b25
R b31 a2 b33b13 b34a4 a5
R4 b41 b42 a3 a4 a5
R5 a1 b52 b53 b13 b54a4 a5
TU → S
P Q S T U
R1 a1 b12 b13 a4 b15
R2 a1 a2 b23 b13 b24a4 b25
R b31 a2 b33 b13 a3 b34a4 a5
R4 b41 b42 a3 a4 a5
R5 a1 b52 b53 b13 a3 b54a4 a5
KTU SU → P
R1
R2
P
a1
a1
STUDENTS
Q
b12
a2
S
b13
b23 b13
T
a4
b24a4
U
b15
b25
R b31 a1 a2 b33 b13 a3 b34a4 a5
R4 b41 a1 b42 a3 a4 a5
R5 a1 b52 b53 b13 a3 b54a4 a5
As the third row is has all the cells with a-values, the decomposition is loss-less.
Full credit should be given only if the matrix corresponding to processing each functional
dependency is shown separately. Partial credits proportional to the extent up to which the
computation is correct.
PART E
Answer any four full questions
15. Consider the tables R (A, B, C), T(D,E,F), S(G, H) and U(A,D, G, I) where A, D and G in U (10)
are foreign keys referring to the primary keys with the same names. Show an initial
query tree for the following query and optimize it using the rules of heuristics:
select B, E, G, H, I
from R, T, S, U
10
1 mark
After pushing down selection
KTU STUDENTS
3 marks
After replacing cross-product
product-followed-by-selection by Join
11
3 marks
KTU STUDENTS
3 marks
If all the above steps are accurate, full credit can be given. If aany
ny intermediate step is
missing, or some steps / final tree are incorrect, reduce marks proportionally.
16 Consider a file with 2,00,000 records stored in a disk with fixed length blocks of size 256 bytes. Each (10)
record is of size 50 bytes. The prima
primary
ry key is 4 bytes and block pointer is 6 bytes. Compute the
12
Given data :
Number of records (n)= 200000
Block size (B) = 256 bytes
Record size (r) = 50 bytes
(i) bfrdata = floor(256/50) = 5 1 mark
(iv) Number of first level index records = number of data blocks = 40000
Number first level index blocks = ceil(40000/ bfrindex) = ceil(40000/25)= 1600
2 marks
(v) Number of second level index records = number of first level index blocks =
1600
Number second level index blocks = ceil(1600/ bfr index) = ceil(1600/25)= 64
KTU STUDENTS
Number of third level index records = number of first level index blocks = 64
Number third level index blocks = ceil(
ceil(64/ bfrindex) = ceil(64/25)=
Only an argument
rgument of the correctness of 2PL with a supporting example is expected.
Description of the 2PL protocol is not expected at all.
In 2PL the locks granted in the growing phase and revoked in the shrinking phase.
Therefore a transaction, say T1T1, is granted a lock, the other transaction say T2, has to wait
until the locks are released. This leads to a scenario where the transactions are serialized in
13
KTU STUDENTS
In the diagram DEPATMENT NUMBER is the non
non-key
y ordering filed and for each unique
value there is block pointer.
diagram 1 mark, explanation:
explanation 2 marks
Secondary index: a typical diagram showing how the index is organized and brief
explanation with the following points:
Secondary index is dense inde
index and is formed based on a non-ordering
ordering field.
field
The pointer field of each index record contains the block address or record address
of the record with the key value of the index record.
14
In the diagram there iss an index record for every value of the index key is the non-key
ordering filed and for each unique value there is block pointer.
diagram 1 mark, explanation:
explanation 2 marks
A diagram similar to the pne showing the types of nodes, node structure and pointer types
KTU STUDENTS
and possibly some some sample values.
3 marks
A brief explanation of the way values are organized, with the following points, is
expected:-
(i) There are n values and n+1 pointers in an internal node for some n
(ii) The first pointer points to the sub
sub-tree
tree containing values less than or equal to
the first value.
(iii) kth pointer points to a sub
sub-tree
tree containing values less than or equal to the kth
value and greater than (k
(k-1)th value.
(iv) (n+1)th pointer points to sub
sub-tree
tree containing values greater than nth value.
2 marks
Scan backwards from end of log to find the most recent <check point> record and continue
scanning backwards till a <Ti, start… start…>. Starting
tarting from Ti or later with <Ti, commit>,
execute redo (Ti). (In the example, T2 and T3)
3 marks
19. a. Illustrate lost-update
update and dirty
dirty-read problems with suitable examples. (4)
KTU STUDENTS
updated by T2 and hence the original value is lost.
Dirty-read problem:- The value read by transaction is the one written by a transaction that
has been rolled back after fail
failure. In the example, if the transaction T1 writes X and fails at
later stage and roll back, the value of X read by T2is a dirty value.
16
T1
[r1(z), w2(z)]
T2 T3
[r3(y), w2(y)]
The schedule is serializable since there is not cycle in the precedence graph.
KTU
20.
STUDENTS
Full credit to be given, if the graph is shown with conflicting instructions as labels and
state why the schedule is serializable.
a. Write a small RDF document and show its equivalent graph structure.
6 marks
A very simple RDF textual description as XML document or RDF triples and the
corresponding graph structure is expected.
Sample:
XML
Triples:
(http://www.w3schools.com/rdf, author, ‘Jan Egil refsnes’)
(http://www.w3schools.com/rdf, homepage, http://www.w3schools.com)
Graph:
17
Document: 2 marks
Graph: 2 marks
b. List out any three salient features of Big data. (3)
Any three of the following feature to be listed
Volume: The quantity of generated and stored datadata.
Variety: The type and nature of the data.
Velocity: The speed at which the data is generated and processed.
Variability: Inconsistency of the data.
Veracity: The quality of captured data
data.
1 mark/feature = 3 marks
c. How is GIS databases different from conventional databases? (3)
Highlight any three off the following features with a one/two line explanation of
the same.
(i) Location reference: Spatial location information has to be maintained in
KTU (ii)
STUDENTS
the form coordinates.
Temporal data: contains data that changes with respect to time.
(iii) Complex spatial information
information:: spatial features such as points, lines,
polygons etc. are to be represented and managed.
(iv) Field-based
based representation of the world as a continuous function of
attributes that varies in spatially. 1 mark/feature = 3marks
18