1324502DA Databases Workbook
1324502DA Databases Workbook
Workbook 2025
© Copyright: Subject matter to MADE EASY Publications, New Delhi. No part of this book may be reproduced or utilised in any form without the written permission.
Contents
2. Normalization ............................................ 12
this book may be reproduced or utilised in any form without the written permission.
Description Sheet
DATABASES
© Copyright: Subject matter to MADE EASY Publications, New Delhi. No part of this book may be reproduced or utilised in any form without the written permission.
conceptual (logical) schema of levels of
abstraction?
(a) Allows data access to be customized at the
Q.1 A relation (from the relational database model) level of individual users.
consists of a set of tuples, which implies that
(b) Describe all data that is actually stored in
(a) relational model supports multi-valued the database.
attributes whose values can be represented
(c) Summarize flow the relation described in the
in sets.
conceptual schema are actually on disk.
(b) for any two tuples, the values associated
(d) All the above
with all of their attributes may be the same.
(c) for any two tuples, the value associated with Common Data for Q.5 & Q.6
one or more of their attributes must differ. Consider the following ER diagram:
(d) all tuples in a particular relation may have
different attributes. M1 M2 M3 P1 P2 N1 N2
© Copyright : www.madeeasypublications.org
Workbook 5
Q.8 Consider a relation geq which represents (c) Summarize how the relation described in the
© Copyright: Subject matter to MADE EASY Publications, New Delhi. No part of this book may be reproduced or utilised in any form without the written permission.
“greater than or equal to”, that is (x, y ) ∈ geq conceptual schema are actual on disk.
only if y ≥ x: (d) All the above
CREA
(CREA
CREATE TE T ABLE geq
TABLE
lb integer NOT NULL, Q.11 The following table has two attributes A and C
ub integer NOT NULL, where A is the primary key and C is the foreign
primary key lb key referencing A with on delete cascade.
Foreign key (ub) references geq on delete A 2 3 4 5 7 9 6
cascade); C 4 4 3 2 2 5 4
Which of the following is possible if a tuple (x, y )
The set of all tuples that must be additionally
is deleted?
deleted to preserve referential integrity when the
(a) A tuple (z, w ) with z > y is deleted
tuple (2, 4) is deleted is
(b) A tuple (z, w ) with z > x is deleted
(a) (3, 4) and (6, 4)
(c) A tuple (z, w ) with w < x is deleted
(b) (5, 2) and (7, 2)
(d) The deletion of (x, y ) is prohibited
(c) (5, 2), (7, 2) and (9, 5)
Q.9 Given the following statements: (d) (3, 4), (4, 3) and (6, 4)
S1: A foreign key declaration can always be
Q.12 Which of the following ER diagram represents
replaced by an equivalent check assertion
given requirement?
in SQL.
“Every professor teaches exactly one course
S2 : Given the table R(a, b, c) where a and b
and Every course must be taught by some
together form the primary key, the following
professor”.
is a valid table definition.
CREATE TABLE S ( Semester
d INTEGER,
(a) Professor Teaches Course
e INTEGER,
PRIMARY KEY (d ),
FOREIGN KEY (a) references R) Semester
Which one of the following statements is ssn cid
CORRECT
CORRECT?
(a) S1 is TRUE and S2 is FALSE (b) Professor Teaches Course
© Copyright : www.madeeasypublications.org
6 Data Science & Artificial Intelligence • Databases
Common Data for Q.13 & Q.14 Q.16 1 : N relationship in E-R diagram is implemented
© Copyright: Subject matter to MADE EASY Publications, New Delhi. No part of this book may be reproduced or utilised in any form without the written permission.
Consider the following ER diagram: in relation model as
(a) foreign keys are added on both sides
A B C D E F
(b) relation corresponding to ‘1’ side is modified
to include foreign key of the relation on the
E1 R1 E2
1 1 N side
1 (c) primary keys are added on both sides
R2 (d) relation corresponding to ‘N’ side is
1 modified to include foreign key of the relation
E3 on the ‘1’ side.
FirstName A B C I J K
Salary
BirthDate
Name MiddleName
EmpID Employee E1 R5 E4
LastName
Supervisor Supervisee 1 M
1 SUPERVISION N R1 R3
D
1 N
Which of the possible relations if the above M
E E2 R2 E3 R4
ERD is mapped into a relational model? M 1 1
(a) Employee (EmpID, BirthDate, Salary, F
G H
Name(FirstName, MiddleName, LastName))
(b) Supervision (EmpID,BithDate, Salary, Q.18 How many minimum relations required for the
Name(FirstName, MiddleName, LastName), above ER diagram?
EmpId) (a) 3 (b) 4
(c) Supervisor (SupervisorID, BirthDate, Salary, (c) 5 (d) 6
Name(FirstName, MiddleName, LastName),
EmpID), {EmpID}) Q.19 How many minimum foreign keys required for
minimized ER diagram into relations?
(d) Employee (EmpID, BirthDate, Salary,
Name(FirstName, MiddleName, LastName), (a) 3 (b) 4
SupervisorID) (c) 5 (d) 5
© Copyright : www.madeeasypublications.org
Workbook 7
Q.20 Which of the statement true for logical data Q.24 Which of the following statement true for
© Copyright: Subject matter to MADE EASY Publications, New Delhi. No part of this book may be reproduced or utilised in any form without the written permission.
independence? physical schema of the levels of abstraction?
(a) Changes of physical file may not effect table (a) Allows data access to be customized at the
schemas. level of individual users.
(b) Changes of conceptual definition of table (b) Describe all data that is actually stored in
may not effect application programming. the database.
(c) Changes of storage file index may pot effect (c) Summarize how the relation described in the
table definition (conceptual schema). conceptual schema are actually on disk.
(d) None of the above (d) All the above
Q.21 Consider the following statements. Q.25 Consider the following Entity Relationship
1. An entity integrity constraint states that no Diagram (ERD).
primary key value can be null.
2. A referential integrity constraint is specified QualifiedDate
between two relations. M N
PERSON QUALIFICATION EXAM
3. A foreign key cannot be used to refer to its
own relation.
Name NID ExamID ExamName
Identify which of the above statements is/are
correct? Which of the following possible relations will
(a) Only 1 not hold if the above ERD is mapped into a
(b) Only 2 relation model?
(c) Only 2 and 3
(a) Person (NID, Name)
(d) Only 1 and 2
(b) Qualification (NID, ExamID, QualifiedDate)
(c) Exam (ExamID, NID, ExamName)
Q.22 A B C D E F
(d) Exam (ExamID, ExamName)
Q.23 Which of the following statement true for (a) A key with no Null’s
physical data independence? D key with no Null’s
(a) Changes of conceptual definition of the
(b) A key with allowed Null’s
table may not effect application program.
D key with no Null’s
(b) Changes of physical storage file may not
(c) A key with no Null’s
effect conceptual definition of table.
D key with allowed Null’s
(c) Changes of view definition not effect
conceptual definition of the table. (d) A key with allowed Null’s
© Copyright : www.madeeasypublications.org
8 Data Science & Artificial Intelligence • Databases
© Copyright: Subject matter to MADE EASY Publications, New Delhi. No part of this book may be reproduced or utilised in any form without the written permission.
Consider the following ER diagram: (c) 5 (d) 4
[GATE-2004]
[GATE-2004]
A B
M Q.31 A B C D E F
E1 R6
1 1
R4 E1 R E2
R1 N
C
M 1
M How many minimum relations required which
E2 R2 E3 R5
M 1 N satisfy 1NF?
D 1 M E
G H (a) 1 (b) 2
R3 (c) 3 (d) 4
R7 E4
Q.32 Which of the following is not the responsible of
Q.27 How many minimum relations required for the DBA?
above ER diagram? (a) Design the logical and physical schemas,
(a) 5 (b) 4 as well as widely used pointers of the
external schema.
(c) 6 (d) 7
(b) Security and authorization.
Q.28 How many foreign keys required for the (c) Concurrency control of the two or more
minimized relations of the above ER diagram? concurrent execution of transaction.
(a) 7 (b) 8 (d) Data availability and recovery from failure.
(c) 9 (d) 5
Q.33 The relationship between two entity types A and
Q.29 How many total number of attributes for B is 1:1 and the relationship is optional at the A
minimized relations of the above ER diagram end. Only 50% of B entities are related to an A
(a) 15 (b) 14 entity. Now consider mapping these entity types
(c) 16 (d) 17 into relations.
Select the best statement from the following list.
Q.30 Consider the following Entity Relationship
(a) A and B should be kept separate with the
Diagram (ERD), where two entities E1 and E2
have a relation R of cardinality 1 : m. foreign key in the A relation.
(b) A and B should be kept separate with a
1 m
E1 R E2 foreign key in both A and B.
(c) A and B should be kept separate with the
The attributes of E1 are A11, A12 and A 13 where
foreign key in the B relation.
A11 is key attribute. The attributes of E2 are
(d) None of the above
A21, A22, and A23 where A21 is the key attribute
and A23 is a multi-valued attribute. Relation R
does not have any attribute. A relational
database containing minimum number of tables
with each table satisfying the requirements of
the third normal form (3NF) is designed from Q.34 Relation R(A B C D E F). How many super keys
the above ERD. The number of tables in the in R if {A, BC, CD} candidate keys.
database is
© Copyright : www.madeeasypublications.org
Workbook 9
© Copyright: Subject matter to MADE EASY Publications, New Delhi. No part of this book may be reproduced or utilised in any form without the written permission.
Employee Manages Dept
Subid
Subid
© Copyright : www.madeeasypublications.org
10 Data Science & Artificial Intelligence • Databases
(a) Minimum 4 tables are required to represent (c) Manipulation and processing of database
© Copyright: Subject matter to MADE EASY Publications, New Delhi. No part of this book may be reproduced or utilised in any form without the written permission.
X, Y, Z, R and S (d) Definition of physical structure of database
(b) The one of the table will be {X1, X2, X3, Y1} system
where X1 is primary key and Y1 references
[Ans: (c)]
Y
(c) The one of the table will be {Y1, Z1, Z2} where T3. Which of the following is not part of Data
Y1 is primary key Definition Language (DDL)
(d) {Y1, Y2} is one of the table where Y1 is 1. Deleting relations.
primary key. 2. Defining.
3. Specifying the security and authorization for
Q.42 Given the basic ER and relational modes which
relation.
of the following are correct?
4. Inserting tuples, deleting tuples.
(a) An attribute of an entity can have more than
5. Physical storage structure information.
one value.
(a) 3 and 5 (b) Both 1 and 4
(b) An attribute of an entity can be composite.
(c) 4 only (d) 3 and 2
(c) In a row of relational table an attribute can
have more than one value. [Ans: (c)]
(d) In a row of a relational table an attribute can
T4. View in a database system are important
have exactly one value or a null value.
because:
Q.43 Consider a relation scheme R = (A, B, C, D, E, 1. They improve the efficiency of query
F). The functional dependencies on R is {A → execution.
B, BC → D, D → A, E → C}. Which of the 2. They help provide data independence.
following is true? 3. They allow the schema to change without
(a) AEF is candidate key of R. forcing existing applications to be
(b) BEF is candidate key of R. recompiled.
(c) DEF is candidate key of R. 4. They help with access control by allowing
(d) BCF is candidate key of R. users to see only a particular subset of the
data in the database.
(a) 2 and 4 (b) 1 and 4
(c) 1 and 3 (d) 2 and 3
[Ans: (a)]
T1. Consider a relation R(A, B, C, D, E) with the T5. The following two questions refer to the relational
following functional dependencies: schema R(A, B, C, D, E, F, G, H) and the
ABC → DE and D → AB following functional dependencies over R:
T2. DML is provided for Q.2 One of the four functional dependencies can
(a) Description of logical structure of database be removed without altering the key. Which
(b) Addition of new structures in the database one?
system EFG → H
[Ans: ((EFG )]
H)]
© Copyright : www.madeeasypublications.org
Workbook 11
T6. A database of research articles in a journal T7. Consider the given ERD:
© Copyright: Subject matter to MADE EASY Publications, New Delhi. No part of this book may be reproduced or utilised in any form without the written permission.
uses the following schema.
ssn Ename rating did dname address
(VOLUME, NUMBER, STARTPAGE, ENDPAGE,
TITLE, YEAR, PRICE)
Emp Manages Dept
The primary key is (VOLUME, NUMBER,
STARTPAGE, ENDPAGE) and the following
functional dependencies exist in the schema. Works
BelongsTo
(VOLUME, NUMBER, STARTPAGE, ENDPAGE)
→ TITLE
(VOLUME, NUMBER) → YEAR
childs
(VOLUME, NUMBER, STARTPAGE, ENDPAGE)
→ PRICE name age gender
The database is redesigned to use the following
schemas. How many relational tables for given ERD?
(VOLUME, NUMBER, STARTPAGE, ENDPAGE, [Ans: (4)]
TITLE, PRICE) T8. Consider the following relational schema:
(VOLUME, NUMBER, YEAR) R(A, B, C, D, E) how many superkeys in relation
Which is the weakest normal form that the new R if every two attributes of relation R is candidate
database satisfies, but the old one does not? keys?
(a) 1NF (b) 2NF [Ans: (26)]
(c) 3NF (d) BCNF
[GA TE-2016, Ans: (b)]
[GATE-2016,
© Copyright : www.madeeasypublications.org
Databases
2 Normalization
© Copyright: Subject matter to MADE EASY Publications, New Delhi. No part of this book may be reproduced or utilised in any form without the written permission.
on which the following functional dependencies
hold: {A → B, BC → D, E → C, D →A}. What
are the candidate keys of R?
Q.1 Consider the following relational schema: (a) AE, BE (b) AE, BE, DE
R(ABCDEGH) with FD set {AB → C, AC → B, (c) AEH, BEH, BCH (d) AEH, BEH, DEH
AD → E, B → D, BC → A, E → G} [GATE-2005]
[GATE-2005]
The following relations are sub relations of the
Q.6 A relation Empdtl is defined with attribute
relation R.
empcode (unique), name, street, city, state and
(i) R1(ABC)
pincode. For any pincode, there is only one city
(ii) R2(ABCD)
and state. Also, for any given street, city and
(iii) R3(ABCEG) state, there is just one pincode. In normalization
How many sub relations of R in BCNF? terms, Empdtl is a relation in
(a) 1 (b) 2 (a) 1NF only
(c) 3 (d) 0 (b) 2NF and hence also in 1NF
(c) 3NF and hence also in 2NF and 1NF
Q.2 Consider a relation with schema R(A, B, C, D) (d) BCNF and hence also in 3NF, 2NF an 1NF
and functional dependencies {AB → C, C → D, [GA
[GATETE IT-2004]
IT-2004]
D → A} what is the highest normal form?
(a) 1NF (b) 2NF Q.7 Consider the following relation R(ABC) with FD
(c) 3NF (d) BCNF set {A → B, C → B, C → B} relation R
decomposed into
Common Data Questions for Q.3 to Q.4:
(i) R1(AB) R2(BC)
Consider the following relational schema R(A, B, C,
(ii) R1(AC) R2(BC)
D, E, F) and functional dependency set {AB → C,
C → A, BC → D, ACD → B, BE → C, EC → AF, CF → (iii) R1(AB) R2(AC)
BD, D → E}. How many of the above decompositions are
dependency preserving decompositions?
Q.3 How many candidate keys for relation R?
(a) 1 (b) 2
(a) 7 (b) 4
(c) 3 (d) 0
(c) 5 (d) 6
Q.8 A relation with 2 attributes is always in
Q.4 What is highest NF satisfied by relation R? (a) 4NF (b) BCNF
(a) 1NF (b) 2NF (c) 5NF (d) DK/NF
(c) 3NF (d) BCNF [DRDO-2009]
© Copyright : www.madeeasypublications.org
Workbook 13
Q.9 Consider the following relation R(TUVWXYZ) Q.14 An RDBMS with 3 attributes has the following
© Copyright: Subject matter to MADE EASY Publications, New Delhi. No part of this book may be reproduced or utilised in any form without the written permission.
and FD set {TU → VW, TY → W, WX → Y, V → Z, functional dependencies A → B A → C C → B
Y → X, Z → T} (a) 2NF (b) 3NF
How many number of candidate keys in relation (c) 4NF (d) BCNF
R? [DRDO-2009]
(a) 3 (b) 4
Q.15 Consider two sets of functional dependencies
(c) 5 (d) 6
F and G if F = {A → C, AC → D, E → AD,
Q.10 A given relation is known to be in third normal E → H} then the equivalent G is
form. Select the statement which can be inferred (a) G = {A → CD, E → AH}
from this. (b) G = {A → CH, E → ADH}
(a) All attributes contribute to the primary key (c) G = {A → CD, E → H}
(b) Each non-key attribute determine the (d) G = {A → AH, E → CH}
primary key Q.16 Let R (A, B, C, D) be a relational schema wit the
(c) Each non-key attribute is determine by the following functional dependencies: A → B,
primary key B → C, C → D and D → B. The decomposition
(d) Every determinant is a candidate key of R into (A, B), (B, C) and (B, D)
(a) gives a lossless join, and is dependency
Q.11 For a relational schema R, K1 and K2 are the
preserving
only candidate keys. R has a functional
(b) gives a lossless join, but is not dependency
dependency X → A where X is set of attributes
preserving
and A is an attribute. It is known that A∈ K1
(c) does not give a lossless join, but is
and A∉K2 and X is not a superkey. Which of
dependency preserving
the following is true?
(d) does not give a lossless join and is not
(a) R could be in BCNF
dependency preserving
(b) R is surely not in BCNF, but could be in 3NF
[GA TE IT
[GATE -2008]
IT-2008]
(c) R is surely not in 3NF, but could be in 2NF
(d) R is surely not in 2NF, but could be in 1NF Q.17 Let R be a relationship schema and let F be a
[ISRO-2009] set of functional dependencies on R. Let R1 and
R2 form a decomposition of R, F+ must contain
Q.12 Which of the following relation is in BCNF?
(a) R1 ∪ R2 → R1 or R1 ∪ R2 → R2
(a) R(A, B, C, D) with FD’s {AB → C, BC → D,
(b) R1 ∪ R2 → R1 or R1 ∩ R2 → R
CD → A, AD → B}
(c) R1 ∪ R2 → R2 or R1 ∩ R2 → R
(b) R(A, B, C, D, E) with FD’s {AB → C, DE → C, (d) R1 ∩ R2 → R1 or R1 ∩ R2 → R2
B → D} [DRDO-2009]
(c) R(A, B, C, D, E) with FD’s {AB → C, C → D,
D → B} Q.18 Which of the following relation can decompose
(d) None of these into BCNF with dependency preserving and
lossless join decomposition.
Q.13 Which of the following functional dependencies
(i) R(ABCDE)
implied in the given FD set {AB → CD, AF → D,
DE → F, C → G, F → E, G → A}. {AB → C, C → AB, C → D, D → E}
(a) AB → F (ii) R(ABCDE)
(b) BG → E {AB → C, C → A, C → D, D → E}
(c) CF → D
(a) Only (i) (b) Only (ii)
(d) AF → B
(c) Both (i) and (ii) (d) None of these
© Copyright : www.madeeasypublications.org
14 Data Science & Artificial Intelligence • Databases
Linked Answer for Q.19 & Q.20: Q.24 Let R (A, B, C, D, E, P, G) be a relational schema
© Copyright: Subject matter to MADE EASY Publications, New Delhi. No part of this book may be reproduced or utilised in any form without the written permission.
Relation R has eight attributes ABCDEFGH. Fields of in which the following functional dependencies
R contain only atomic values. are known to hold: AB → CD, DE → P,
F = {CH → G, A → BC, B → CFH, E → A, F → EG} is C → E, P → C and B → G. The relational schema
a set of functional dependencies (FDs) so that F is R is
exactly the set of FDs that hold for R. (a) in BCNF
(b) in 3NF, but not in BCNF
Q.19 How many candidate keys does the relation R
(c) in 2NF, but not in 3NF
have?
(d) not in 2NF
(a) 3 (b) 4
[GA
[GATETE IT -2008]
IT-2008]
(c) 5 (d) 6
[GA TE-2013]
[GATE-2013] Q.25 The relation scheme student performance
Q.20 The relation R is (name, courseno, rollno, grade) has the following
(a) in 1NF, but not in 2NF functional dependencies
(b) in 2NF, but not in 3NF name, courseno → grade
(c) in 3NF, but not in BCNF rno, courseno → grade
(d) in BCNF name → rollno
[GATE-2013]
[GATE-2013] rollno → name
Q.21 The best normal form the instance is The highest normal form of this relation scheme
is
A B C D E F (a) 2NF (b) 3NF
(c) BCNF (d) 4NF
Q.26 Consider the relation r (A, B, C, D, E) and the
set F = {AB → CE, E → AB, C → D}. What is
the highest normal form of this relation?
(a) 1NF (b) 2NF (a) 1NF (b) 2NF
(c) 3NF (d) BCNF (c) 3NF (d) BCNF
© Copyright : www.madeeasypublications.org
Workbook 15
Q.29 Consider the following relational schema Q.33 Consider the following relational schema
© Copyright: Subject matter to MADE EASY Publications, New Delhi. No part of this book may be reproduced or utilised in any form without the written permission.
R(ABCDEFG) with FD set {AB → C, BC → A, R(ABCD). Which of FD set of R does not have
B → D, D → E} BCNF decomposition [i.e. not possible to
How many minimum relations required to decompose BCNF with lossless join and
decompose R into BCNF which satisfy lossless dependency preserving decomposition].
join and dependency preserving decompositions? (i) {B → C, D → A}
(a) 3 (b) 2 (ii) {ABC → D, D → A}
(c) 4 (d) 5 (iii) {AB → CD, C → A, D → B}
(a) (ii) only (b) (ii) and (iii)
Q.30 Consider the following functional dependencies
(c) (i) and (ii) (d) (i), (ii) and (iii)
in a database:
Data_of_Birth → Age Q.34 The relation scheme student Performance
Age → Eligibility (name, courseNo, rollNo, grade) has the
Name → Roll_number following functional dependencies:
Roll_number → Name name, courseNo → grade
Course_number → Course_name RollNo, courseNo → grade
Course_number → Instructor name → rollNo
(Roll_number; Course_number) → Grade rollNo → name
The relation (Roll_number; Name, Date_of_birth, The highest normal form of this relation scheme is
Age) is (a) 2NF (b) 3NF
(a) in 2NF but not in 3NF (c) BCNF (d) 4NF
(b) in third normal form but not in BCNF [GA TE-2004]
[GATE-2004]
(c) in BCNF Q.35 Consider the relation R = {A, B, C, D, E, F, G, H,
(d) in none of the above I, J} and set of FDS are F = {AB → C, A → DE,
[GA TE-2003]
[GATE-2003] B → F, F → GH, D → IJ} if we decompose R into
Q.31 The following functional dependencies are 3NF, then possible tables are
given: AB → CD, AF → D, DE → F, C → G, F → E, (a) {D, I, J} {A, D, E} {F, G, H} {B, F} {A, B, C}
G → A. Which one of the following options is (b) {D, I, J} {A, C, E} {F, G, H} {B, F} {A, D, C}
false? (c) {F, G, H} {D, I, J} {A, D, E, B, F} {A, B, C}
(a) {CF}+ = {ACDEFG} (d) None of these
(b) {BG}+ = {ABCDG}
Q.36 Consider the following relation R(ABCDE) with
(c) {AF}+ = {ACDEFG}
(d) {AB}+ = {ACDFG} [GA TE-2006]
[GATE-2006] functional dependency set {A → BC, CD → E,
B → D, E → A} decomposed relation R into
Q.32 Relation R with an associated set of functional R1(ABC) R2(CDE) which of the statement true
dependencies, F is decomposed into BCNF. about decomposition?
The redundancy (arising out of functional (a) Lossless join decomposition and
dependencies) in the resulting set relations is dependency preserving decomposition.
(a) Zero (b) Lossless join decomposition but not
(b) More than zero but less than that of an dependency preserving decomposition.
equivalent 3NF decomposition
(c) Lossy join decomposition and dependency
(c) Proportional to the size of F+
preserving decomposition.
(d) Indeterminate
(d) Lossy join decomposition and not
[GATE-2002]
[GATE-2002]
dependency preserving decomposition.
© Copyright : www.madeeasypublications.org
16 Data Science & Artificial Intelligence • Databases
© Copyright: Subject matter to MADE EASY Publications, New Delhi. No part of this book may be reproduced or utilised in any form without the written permission.
lossless join decomposition and dependency (c) 2 (d) 0
preserving decomposition satisfied or not?
(a) R(ABCDEFGHIJ) and FD sets {AB → C, Q.40 Relation R is decomposed using a set of
Q.40
A → DE, B → F, F → GH, D → IJ} functional dependencies, F and relation S is
decomposed using another set of functional
(i) D1 = {DIJ, ADE, FGH, BF, ABC}
dependencies G. One decomposition is definitely
(ii) D2 = {DIJ, ACE, FGH, BF, ADC}
BCNF, the other is definitely 3NF, but it is not
(iii) D3 = {FGH, DIJ, ADEBF, ABC}
know which is which. To make a guaranteed
(b) R(ABCDEGH) and FD’s sets {AB → C, identification, which one of the following tests
AC → B, AD → E, B → D, BC → A, E → G} should be used on the decomposition? (Assume
(i) D1 = {AB, BC, ABDE, EG} that the closures of F and G are available).
(ii) D2 = {ABC, ACDE, ADG} (a) Dependency-preservation
(c) R(ABCDEG) and FD’s sets {AB → C, (b) Lossless-join
AC → B, AD → E, B → D, BC → A, E → G} (c) BCNF definition
(i) D1 = {AB, BC, ABDE, EG} (d) 3NF definition
(ii) D2 = {ABC, ACDE, ADG} [GA TE-2002]
[GATE-2002]
(d) R(ABCDEF) and FD’s sets F = {A → B, Q.41 Consider the following relational schemas for a
AC → DE, BD → F} library database.
Decomposed into {AB, BDF, ACDE} Book (Title, Author, Catalog_no, Publisher, Year,
Q.38 Let R be an RDBMS with attributes A1, A2, ..., price)
A. Let S denotes the set {A1, A2, ..., An}. Let Collection (Title, Author, Catalog_no)
T ⊆ S be a set of attributes that forms a with the following functional dependencies:
candidate key. Then which of the following is/ 1. Title, Author → Catalog
are True? 2. Catalog_no → Title, Author, Publisher, Year
P : T→S–T 3. Publisher, Title, Year → Price
Q : ∃P ⊂ T s.t. P → S – P Assume {Author, Title} is the key for both
R : ∀ Q ⊇ T s.t. Q → S – Q schemes: which of the following statements is
(a) Only P is true true?
(a) Both Book and Collection are in BCNF
(b) P and Q are true
(b) Both Book and Collection are 3NF only
(c) P and R are true
(c) Book is in 2NF and Collection is in 3NF
(d) Q and R are true
(d) Both Book and Collection are in 2NF only
Q.39 Consider the following relation R(ABC) with FD [GA TE-2008]
[GATE-2008]
set {A → B, C → B, C → B} relation R Q.42 If the set of functional dependencies F = {A →
decomposed into BC, CD → E, E → C, D → AEH, ABH → BD,
(i) R1(AB) R2(BC) DH → BC}, then what is the canonical cover of F?
(a) {A → BC, C → E, E → C, D → AE, DH → B}
(ii) R1(AC) R2(BC)
(b) {A → BC, E → C, D → AEH, AH → D}
(iii) R1(AB) R2(AC) (c) {A → B, E → C, D → AH, AH → D}
How many of the above decompositions are (d) {A → C, C → E, E → C, D → AH, D → BC}
lossless join decompositions? [JNUEE-2007
[JNUEE-2007]
© Copyright : www.madeeasypublications.org
Workbook 17
Q.43 Which-one of the following statements about Q.50 Consider the following relation R(ABCDEH) with
© Copyright: Subject matter to MADE EASY Publications, New Delhi. No part of this book may be reproduced or utilised in any form without the written permission.
normal forms is FALSE? functional dependencies {A → BC, CD → E,
(a) BCNF is stricter than 3NF E → C, D → AEH, ABH → BD, DH → BC}. How
(b) Loss less, dependency-preserving many candidate keys of the above relation R?
decomposition into 3NF is always possible
(c) Loss less, dependency-preserving
decomposition into BCNF is always possible
(d) Any relation with two attributes is BCNF
[GA TE-2005]
[GATE-2005] Q.51 Which-one of the following statements about
normal forms is TRUE?
(a) BCNF is stricter than 3NF.
(b) Lossless decomposition and dependency
preserving in 3NF is always possible.
Q.44 Consider the following relation R(ABCDEFG) (c) Lossless decomposition dependency
with functional dependencies {AB → CD, preserving in BCNF is always possible.
AF → D, DE → F, C → G, F → E, G → A}. How (d) Any relation with two attributes is BCNF.
many candidate keys in the above relation R?
Q.52 Empdt1(empcode, name, street, city, state,
Q.45 How many minimum relations required to pincode).
decompose following relation R(ABCD) WITH For any pincode, there is only one city and state.
FD’s {A → B, C → D} with lossless join and Also, for given street, city and state, there is
dependency preserving BCNF decomposition? just one pincode. In normalization terms, empdt1
is a relation in
Q.46 Find minimal cover of the following functional
(a) 1NF (b) 2NF
dependencies (c) 3NF (d) BCNF
I. {A → BCDEF, BC → ADEF, B → F, D → E}
Q.53 Relation R is decomposed using a set of
II. {AB → C, D → E, AB → E, E → C}
functional dependencies F and relation S is
III. {AB → C, BC → A, A → BC, B → AC,
decomposed using another set of functional
C → AB}
dependencies G. One of the decomposition is
Q.47 Consider the following relation R(ABCDE) with 3NF and another is BCNF. Assume the closure
FD’s {A → C, BC → E, ED → A}. How many of F and G are available but if not clear which
candidates keys in R? relation is in which normal forms. Which of the
following is true?
Q.48 Relation R(A B C D E F G H I J ) with FD set
(a) Using BCNF definition we can certainly tell
{AB → C, A → DE, B → F, F → GH, D → IJ}.
about the normal forms of F and G.
How many minimum number of relations required
(b) Using dependency preservation we may/
for 2 NF lossless and dependency preserve
may not tell about the normal forms of
decomposition?
F and G.
Q.49 How many number of candidate keys in the
Q.49 (c) Using lossless join we can’t tell about the
following relation R(ABCDEH) with FD’s {A→ normal forms of F and G.
BC, CD → E, E → C, D → AEH, ABH → BD, (d) Using 2NF definition we can find out the
DH → BC}? normal forms of F and G
© Copyright : www.madeeasypublications.org
18 Data Science & Artificial Intelligence • Databases
© Copyright: Subject matter to MADE EASY Publications, New Delhi. No part of this book may be reproduced or utilised in any form without the written permission.
dependencies M → O, NO → P, P → L and
L → MN holds.
Assume R is decomposed into R1(M, O) and
R2(L, M, N, P). Then which of the following is T1. The purpose of schema normalization is to:
correct? 1. Eliminate redundant data stored in the
(a) The above decomposition is lossless join. database.
(b) The highest normal form satisfied by the 2. Reduce the number of joins required to
above decomposition is BCNF. satisfy a query.
(c) The above decomposition does not satisfied 3. Reduce the number of anomalies that can
dependency preserving as O → P does not occur during inserts, deletes, and updates.
4. Convert the data to a canonical form to
preserved.
promote schema integration.
(d) The above decomposition does not satisfy
(a) 1 and 4 (b) 2 and 3
dependency preserving as ON → P does
(c) 1, 2 and 3 (d) 1 and 3
not preserved.
[Ans : ((d
d)]
Q.55 Which of the following options are correct?
T2. Consider the following FD set
(a) A prime attribute can transitively dependent
on a key in a BCNF relation. {AB → C, C → A, BC → D, ACD → B, BE → C,
(b) A relation in which every key has only one EC → AF, CF → BD, D → E}
attribute is in 2NF. Which of the following FD set is minimal cover
(c) A prime attribute can be transitively of given FD set?
dependent on a key in a 3NF relation. (a) {AB → C, C → A, BC → D, BE → C,
(d) There is always a decomposition into Boyce- EC → F, CF → D, D → E}
code normal form that is lossless and (b) {AB → C, C → A, BC → D, BE → D,
dependency preserving. EC → F, CF → B, D → E}
(c) {AB → C, C → A, CD → B, EC → F,
CF → B, D → E}
(d) {AB → C, C → A, BC → D, BE → C,
EC → A, CF → B, D → E}
[Ans : ((b
b)]
© Copyright : www.madeeasypublications.org
Databases
© Copyright: Subject matter to MADE EASY Publications, New Delhi. No part of this book may be reproduced or utilised in any form without the written permission.
operation is not a commutative operation?
(a) Union (b) Intersection
(c) Selection (d) Projection
Q.1
Q.1 Let R and S be two relations with the following
schema Q.5 Given the relations:
R(P, Q, R1, R2, R3) Employee (name, salary, dept no) and
S(P, Q, S1, S2) Dept (dept no, dept name, address)
where {P, Q} is the key for both schemas. Which Which of the following queries cannot be
of the following queries are equivalent? expressed using the basic relational algebra
operations (σ, π, x, , ∪, ∩, —)?
1. ΠP (R S)
(a) Department address of every employee
2. ΠP (R) ΠP (S) (b) Employees whose name is the same as their
3. ΠP (ΠP.Q (R) ∩ ΠP.Q (S)) department name
4. ΠP (ΠP.Q (R) – (ΠP.Q (R) – ΠP.Q (S))) (c) The sum of all employees salaries
(a) Only 1 and 2 (b) Only 1 and 3 (d) All employees of a given department
(c) Only 1, 2 and 3 (d) Only 1, 3 and 4
Q.6 Information about a collection of students is
[GATE-2008]
[GA TE-2008]
given by the relation studInfo (studId, name,
Q.2 Let r and s be two relations over the relation sex). The relation enroll (studId, CourseId) gives
schemes R and S respectively, and let A be an which student has enrolled for (or taken) what
attribute in R. Then the relational algebra course(s). Assume that every course is taken
expression σA = a (r s) is always equal to by at least one male and at least one female
(a) σA = a ( r ) (b) r student. What does the following relational
(c) σA = a ( r ) s (d) None of these algebra expression represent?
[GA TE-2001]
[GATE-2001] πcourseId ((πstudId(σsex = “female” (studInfo))) × πcourseId
Q.3 In SQL, relations can contain null values, and (enroll) – enroll)
comparisons with null values are treated as (a) Courses in which all the female students
unknown. Suppose all comparisons with a null are enrolled
value are treated as false. Which of the following (b) Courses in which a proper subset of female
pairs is not equivalent? students are enrolled
(a) x = 5 not (not (x = 5)) (c) Courses in which only male students are
(b) x = 5 x > 4 and x < 6, where x is an integer enrolled
(c) x ≠ 5 not (x = 5) (d) None of the above
(d) None of the above [GA
GATE TE -2000]
TE-2000] [GATE-2007]
[GATE-2007]
© Copyright : www.madeeasypublications.org
20 Data Science & Artificial Intelligence • Databases
Common Data For Q.7 & Q.8: (b) Relational algebra has the same power as
© Copyright: Subject matter to MADE EASY Publications, New Delhi. No part of this book may be reproduced or utilised in any form without the written permission.
Consider the following relational database schema: relational calculus
employee (emp no, name, address) (c) Relational algebra has the same power as
project (p no. p_name) safe relational calculus
work_on(emp no, p no) (d) None of the above
[GATE-2002]
[GATE-2002]
Q.7 We have a relational algebra expression on the
above schema: Q.10 The relation book (title, price) contains the titles
Πname(employee) – Πname(employee ⊗ work_on) and prices of different books. Assuming that
Here ⊗ denotes natural join operator. Then which no two books have the same price, what does
of the following query best resembles the above the following SQL?
relationship algebra expression? Select title
(a) Find the name of all employees working in from book as B
a project. where (select count (*)
(b) Find the name of all employees working in from book as T
all projects. where T. price> B. Price) < 5
(c) Find the name of all employees who don’t (a) Titles of the four most expensive books
work in all projects. (b) Titles of the fifth most inexpensive book
(d) Find the name of all employees who don’t (c) Titles of the fifth most expensive book
work in any project. (d) Titles of the five most expensive books
[DRDO-2009] [GA TE-2005]
[GATE-2005]
Q.8 Find all addresses of employees working in the Q.11 Let R1(A– , B, C) and R2(D– , E) be two relation
project with p_name = “database”. Which of the schema, where the primary keys are shown
following SQL represents the above query. underlined, and let C be a foreign key in R1
referring to R2. Suppose there is no violation of
(a) SELECT address FROM employee, project
the above referential integrity constraint in the
WHERE (p_name= “database”) ^
corresponding relation instances r1 and r2.
(work_on.emp_no=employee.emp_no)
Which one of the following relational algebra
(b) SELECT address FROM employee, project,
expressions would necessarily produce an
work_on WHERE (p_name=“database”) ^
empty relation?
(work_on.emp_no=employee.emp_no) ^
(work_on.emp_no=employee.emp_no) ^ (a) ΠD (r2 ) − ΠC (r1)
(work_on.p_no-project.p_no) (b) ΠC (r1) − ΠD (r2 )
(c) SELECT address FROM employee, work_on (c) ΠD (r1 C ≠D R2 ) − ΠC (r1)
WHERE (p_name=“database”) ^ (d) ΠC (r1 C = D R2 )
(work_on.emp_no=employee.emp_no) [GATE-2004]
[GATE-2004]
(d) SELECT address FROM project, work_on Q.12 Given relations r (w, x) and s(y, z), the result of
WHERE (p_name=“database”) ^ select distinct w, x
(work_on.emp_no=employee.emp_no)
from r, s
[DRDO-2009] is guaranteed to be same as r, provided
Q.9 With regard to the expressive power of the formal (a) r has no duplicates and s is non-empty
relational query languages, which of the following (b) r and s have no duplicates
statements is true? (c) s has no duplicates and r is non-empty
(a) Relational algebra is more powerful than (d) r and s have the same number of tuples
relational calculus [GA TE-2000]
[GATE-2000]
© Copyright : www.madeeasypublications.org
Workbook 21
Q.13 The relational algebra expression equivalent to Where the primary keys are shown underlined.
© Copyright: Subject matter to MADE EASY Publications, New Delhi. No part of this book may be reproduced or utilised in any form without the written permission.
the following tuple calculus expression: The number of tupelos in the student and Enroll
{tt ∈ r ∧ (t [A] = 10 ∧ t [B] = 20)} is tables are 120 and 8 respectively. What are the
(a) σ(A = 10 ∨ B = 20)(r ) maximum and minimum number of tuples that
(b) σ(A = 10) (r ) ∪ σ(B = 20) (r ) can be present in (Student*Enroll), where ‘*’
(c) σ(A = 10) (r ) ∩ σ(B = 20) (r ) denotes natural join?
(d) σ(A = 10) (r ) – σ(B = 20) (r ) (a) 8, 8 (b) 120, 8
[GA TE-1999]
[GATE-1999] (c) 960, 8 (d) 960, 120
Consider the following Q.14 to Q.15: Q.17 Consider a selection of the form σA≤100(r ), where
Edges of two directed graph stored in data base r is a relation with 1000 tuples. Assume that the
relation Adj(x, y ) [i.e. of there exist edge from vertex attribute values for A among the tuples are
A to B then (A, B) is one record in Adj relation] uniformly distributed in the interval [0, 500].
Which one of the following options is the best
Q.14 Which of relational algebra query retries vertices
estimate of the number of tuples returned by
who out degree atleast two?
the given selection query?
(a) π X Adj ρ X1,Y1 (Adj) (a) 50 (b) 100
X=X1
∧ Y ≠ Y1 (c) 150 (d) 200
[GATE IT
[GATE -2007]
IT-2007]
(b) πX Adj ρX1,Y1 (Adj)
X=X1 Q.18 Consider the relation Student(name, sex, marks)
∧ Y = Y1
where the primary key is shown underlined,
(
(c) πX Adj ρX1,Y1 (Adj)
X=X1 ) pertaining to student in a class that has at least
one boy and one girl. What does the following
(d) π X Adj ρ X1,Y1 (Adj) relational algebra expression produce
X ≠ X1
∧ Y ≠ Y1 Note: ρ is the rename operator)
πname(σsex=female(Student) – πname (Student (sex
Q.15 Which of the query correct representation to
= female ∧ x = male ∧ marks ≤ m) σn, x,m (Student)))
retrieve vertices with only degree two?
(i) SELECT X (a) names of girl student with the highest marks
(b) names of girl student with more marks than
FROM Adj
some boy student
Group by X
(c) names of girl student with marks not less
having count (*) = 2
than some boy student
(ii) πX Adj ρ(Adj) (d) names of girl students with more marks than
X=X1 X1, Y1
all the boy students
∧ Y ≠ Y1
Q.19 Which of the following relational calculus
(a) Only (i) correct
expressions is not safe?
(b) Only (ii) correct
(a) {t∃u ∈ R1 (t [A] = u [A]) ∧ ¬ ∃s ∈ R2 (t [A] =
(c) Both (i), (ii) correct
s [A])}
(d) Both (i), (ii) incorrect
(b) {t∀u ∈ R1 (u [A] = “x” ⇒ ∃s ∈ R2 (t [A] =
Q.16 Consider the following relational schema s[A] ∧ s[A] = u [A]))}
pertaining to a student database (c) {t¬ (t ∈ R1)}
Student (rollno, name, address) (d) {t∃u ∈ R1 (t [A] = u [A]) ∧ ∃s ∈ R2 (t [A] =
Enroll (rollno, courseno, coursename) s[A])} [GA TE-2001]
[GATE-2001]
© Copyright : www.madeeasypublications.org
22 Data Science & Artificial Intelligence • Databases
Q.20 Consider the following database Q.22 Consider a database table T containing two
© Copyright: Subject matter to MADE EASY Publications, New Delhi. No part of this book may be reproduced or utilised in any form without the written permission.
Works (Ename, Comp-name, sex, salary) and columns X and Y each of type integer. After the
the SQL query: creation of the table, one record (X = 1, Y = 1)
is inserted in the table.
Select * W1. Ename
Let MX and MY denote the respective maximum
from Works W1, (Select Avg (sal) AS AVG-SAL, values of X and Y among all records in the table
Comp-name from WORKS WHERE sex = ‘Male’ at any point in time. Using MX and MY, new
GROUP BY comp-name) W2 records are inserted in the table 128 times with
WhereW1 . comp-name = W2.comp-name AND X and Y values being MX + 1, 2∗MY + 1
W1. salary > W2.AVG-sal respectively. It may be noted that each time
after the insertion, values of MX and MY change.
What will be the output?
What will be the output of the following SQL
(a) Retrieves names of all employees who earn query after the steps mentioned above are
more than average salary of all Emp’s of carried out?
their company SELECT Y FROM T WHERE X = 7;
(b) Retrieves names of all male employees who (a) 127 (b) 255
earn more than average salary of all (c) 129 (d) 257
[GATE-2011]
[GATE-2011]
employees of their company
(c) Retrieves names of all employees who earn Q.23 Consider the relation Enrolled (SID, CID) in which
more than average salary of all male (Sid, Cid) is the primary key, and the relation
employees of their company paid (Sid, amount) where sid is the primary key
(d) Retrieves names of all male employees who assume no null values and no foreign keys or
earn more than average salary of all male integrity constraints.
employees of their company Query 1: Select sid from Enrolled where sid in
Q.21 Consider the relational schema given below, (select sid from paid)
where eId of the dependent is a foreign key Query 2: Select sid from paid where sid in
referring to empId of the relation employee
employee. (select sid from Enrolled)
Assume that every employee has at least one
Query 3: Select E.sid from Enrolled E, paid P
associated dependent in the dependent
where E.sid = p.sid
relation.
employee ((empId
empId
empId,, empName, empAge) Query 4: Select sid from paid where exists
dependent( depId, eId
dependent(depId, eId,, depName, depAge) (Select * from Enrolled where enrolled.sid =
paid.sid)
Consider the following relational algebra query:
Which one of the following statement is correct?
ΠempId (employee) − Π empId (employee (a) All queries return identical row sets for any
(empId = eId)∧(empAge ≤ depAge) dependent) database
(b) Query 2 and Query 4 return identical row
The above query evaluates to the set of empIds sets for all database but there exist
of employees whose age is greater than that of databases for which Query 1 and Query 2
(a) some dependent. return different row sets
(b) all dependents. (c) There exist databases for which Query 3
(c) some of his/her dependents. returns strictly fewer rows than Query 2
(d) all of his/her dependents. (d) There exist databases for which Query 4
will encounter an integrity violation at run
[GATE-2014 (Set-3)]
[GATE-2014
time
© Copyright : www.madeeasypublications.org
Workbook 23
Q.24 Consider the table Employee (Empld, name, Which of the following sets is computed by the
© Copyright: Subject matter to MADE EASY Publications, New Delhi. No part of this book may be reproduced or utilised in any form without the written permission.
department, salary) and the two queries Q1, Q2 above query?
below: (a) Names of students who have got an A grade
Assuming that department 5 has more than one in all courses taught by Korth
employee, and we want to find the employee (b) Names of students who have got an A grade
who get higher salary than anyone in the in all courses
department 5, which one of the statement is true (c) Names of students who have got an A grade
for any arbitrary employee table? in at least one of the courses taught by
Q1 Select e.empld Korth
From employee e (d) None of the above [GATE-2003]
[GATE-2003]
where not exists(SELECT * from employee
Q.27 With the help of which of the following relations
S where S.department = ‘5’ and S.salary > operation set we can perform division on
= e.salary) relations?
Q2 Select e.emplD
(a) {π, ×, –} (b) {σ, ×, –}
from employee e (c) {×, –} (d) {×}
where e.salary > any
(SELECT distinct salary from employee S where Q.28 A table T1 in a relational DB has the following
S.department = 5) rows and columns
(a) Q1 is the correct query Roll No. Marks
(b) Q2 is the correct query 1 10
(c) Both Q1 and Q2 produce the same answer 2 20
(d) Neither Q1 nor Q2 is the correct query 3 30
4 NULL
Q.25 One of the following four expression of RA is
The following sequence of SQL statements are
not equivalent to the other three. They are based
executed on table T1
on the relation R(A, B) S(B, C)
Update T1 set marks = marks + 5
(a) πAB (R S)
Select Avg (marks) from T1
(b) R πB (S) What is the output of the select statement
(c) R ∩ (πA(R) × πB(S)) (a) 18.75 (b) 20
(d) πA, R.B (R × S) (c) 25 (d) NULL
Q.26 Consider the set of relations shown below and Q.29 Consider the following relational schema:
the SQL query that follow: employee( e m p I dd,empName,empDept)
Students: (Roll_number, Name, Date_of_birth) customer(custId
custId, custName, salesRepId, rating)
custId
Courses: (Course_number, Cours_name, salesRepId is a foreign key referring to empId
Instructor) of the employee relation. Assume that each
Grades: (Roll_number, Course_number, Grade) employee makes a sale to at least one customer.
select distinct Name What does the following query return?
from Students, Courses, Grades
SELECT empName
where Students. Roll_number = Grades.
FROM employee E
Roll_number
WHERE NOT EXISTS (SELECT custId
and Courses. Instructor = Korth
FROM customer C
and Courses. Course_number = Grades.
WHERE C.salesRepId = E.empId
Course_number
AND C.rating <> ’GOOD’);
and Grades. grade = A
© Copyright : www.madeeasypublications.org
24 Data Science & Artificial Intelligence • Databases
(a) Names of all the employees with at least The relation R contains 200 tuples and the
© Copyright: Subject matter to MADE EASY Publications, New Delhi. No part of this book may be reproduced or utilised in any form without the written permission.
one of their customers having a ‘GOOD’ relation S contains 100 tuples. What is the
rating. maximum number of tuples possible in the
(b) Names of all the employees with at most natural join R S?
one of their customers having a ‘GOOD’ [GATE-2010]
[GATE-2010]
rating.
(c) Names of all the employees with none of Common Data for Q.33 & Q.34:
their customers having a ‘GOOD’ rating. Consider the following relations A, B and C:
(d) Names of all the employees with all their A. Id Name Age
customers having a ‘GOOD’ rating. 12 Arun 60
[GA TE-2014 (Set-3)]
[GATE-2014 Shreya
15 24
99 Rohit 11
B. Id Name Age
15 Shreya 24
Q.30 Consider the following relational schema: 25 Hari 40
98 Rohit 20
R A B C
4 5 6 99 Rohit 11
3 4 5
7 2 9 C. Id Phone Age
8 5 6 10 2200 02
Select *
Q.33 How many tuples does the result of the following
FROM R
relational algebra expression contain? Assume
Where C > ALL (Select B
that the schema of A ∪ B is the same as that
FROM R
of A.
Where A > 10)
(A ∪ B) A.Id> 40 ∨ C.Id<15 C
Q.31 Consider the following relational Schema and
[GATE-2012]
[GATE-2012]
Instance
R A B C
Q.34 How many tuples does the result of the following
4 3 4 SQL query contain?
2 7 2 SELECT A.Id
6 8 5 FROM A
How many tuples resulted by given SQL query? WHERE A.Age >
Select * All ( SELECT B.Age
FROM R as T1 FROM B
WHERE B.Name = ‘Arun’) [GA TE-2012]
[GATE-2012]
Where EXISTS (Select count (*)
FROM R as T2 Q.35 Consider the following relations:
Where T1 . A < T2 . A) R(ABC) A: Primary key with 10 tuples
S(ADE) AD: Primary key with 40 tuples
Q.32 The following functional dependencies hold for
T(DFG) D: Primary key with 30 tuples
relations R(A, B, C) and S(B, D, E):
B→A How many maximum tuples resulted by
A→C R S T?
© Copyright : www.madeeasypublications.org
Workbook 25
Q.36 Consider a database that has the relation Q.38 Which is the subset of SQL commands used to
© Copyright: Subject matter to MADE EASY Publications, New Delhi. No part of this book may be reproduced or utilised in any form without the written permission.
schema CR(StudentName, CourseName). An manipulate Database Structures, including
instance of the schema CR is as given below: tables?
CR (a) Data Definition Language
Student Name Course Name (b) Data Manipulation Language
SA CA (c) Data Described Language
SA CB (d) Data Retrieval Language
SA CC
SB CB
SB CC
SC CA T1. One of the following four expressions of relational
SC CB algebra is not equivalent to the other three.
SC CC They are all based on the relations R(A, B) and
SD CA S(B, C). Indicate which is not equivalent to the
SD CB others.
SD CC (a) π AB (R S) (b) R πB (S)
SD CD (c) R ∩ (π A (R) × πB (S) (d) π A,R,B (R × S)
SE CD
SE CA T2. Consider the following relation:
SE CB family (parent, child, childDOB)
SF CA The intent is that a tuple (p, c, d) means that
SF CB parent p has child c, who was born on date d.
SF CC You may assume that parents do not have two
children of the same name, and that their are no
The following query is made on the database. twins; i.e., no parent has two or more children
T1 ← πCourseName (σStudentName = ‘SA’ (CR)) born on the same day. Here are three queries
we might ask about this data;
T2 ← CR ÷ T1 1. Find for each parent, the youngest child,
The number of rows in T2 is _________. i.e., the set of (p, c) such that p has child c,
[GA TE-2017]
[GATE-2017] and no other child of p has a smaller date
of birth than c does.
2. Find the set of great grandparents of “Amy”.
3. Find all the descendants of “Mike”.
Which of the above queries are expressible in
Q.37 Which of the following is/are correct? relational algebra?
(a) Logical database design is the process of (a) 1 only (b) 1 and 2 only
selecting the data storage and data access (c) 3 only (d) 1, 2 and 3
characteristics of the database. T3. If ∩, ∪, – are given their bag interpretations,
(b) Physical database design is the process of which of the following laws hold?
selecting the data storage and data access (a) R ∪ R = R
characteristics of the database. (b) R ∩ (S ∪ T) = (R ∩ S) ∪ (R ∩ T)
(c) Terminated is a state in transaction. (c) R ∪ (S – T) = (R ∪ S) – T
(d) Partially committed is not a state in transaction. (d) None of these
© Copyright : www.madeeasypublications.org
26 Data Science & Artificial Intelligence • Databases
T4. Consider the following SQL query on the relation T8. The table Arc(x, y ) currently has the following
© Copyright: Subject matter to MADE EASY Publications, New Delhi. No part of this book may be reproduced or utilised in any form without the written permission.
R(A, B) that has no NULL’s. tuples (not there are duplicates): (1, 2), (1, 2),
Select rr. A, rr.B, ss.A, ss.B (2, 3), (3, 4), (3, 4), (4, 1), (4, 1), (4, 1), (4, 2).
From R as rr, R as ss Compute the result of the query:
Where rr.A = ss.A and rr.B = ss.B SELECT a1.x, a2.y , COUNT(*)
Suppose that R has n tuples (not necessarily FROM Arc a1, Arc a2
all distinct). Which of the above conditions is WHERE a1.y = a2.x
the most restrictive correct limitation on m, the GROUP BY a1.x, a2.y
number of tuples (again not necessarily all
Which of the following tuples is in the result?
distinct) in the result? 2. (2, 4, 6)
1. (1, 3, 2)
(a) n ≤ m ≤ n*n (b) n ≤ m ≤ 2n
3. (3, 1, 4) 4. (3, 1, 6)
(c) 0 ≤ m ≤ n (d) m = n
(a) 1 and 3 (b) 1 and 2
T5. Suppose now that R(A, B) and S(A, B) are two (c) 1 and 4 (d) 2 and 3
relations with r and s tuples, respectively (not
T9. The relation R(a, b) may have duplicate tuples.
necessarily distinct). If m is the number of (not
Which of the following queries has a result that
necessarily distinct) tuples in the result of the
is guaranteed not to have duplicates, regardless
SQL query:
of what tuples R contains?
R intersect S; 1. SELECT a FROM R WHERE a = 1
Then which of the following is the most 2. SELECT MAX(b) FROM R GROUP BY a
restrictive, correct condition on the value of m? 3. SELECT a, b FROM R GROUP BY a, b
(a) m = min(r, s) 4. SELECT a FROM R WHERE a NOT IN
(b) 0 ≤ m ≤ r + s (SELECT a FROM R)
(c) min(r, s) ≤ m ≤ max(r, s) (a) 3 and 4 (b) 1 and 2
(d) 0 ≤ m ≤ min(r, s) (c) 3 only (d) 1 and 3
T6. Which of the following is correct? T10. Let two relations r(R) and s(S). Where R and S
(a) a SQL query automatically eliminates are schemas of relation. Consider the following
duplicates points.
(b) SQL permits attribute names to be repeated 1. The division operation r ÷ s, relation is a
in the same relation relation on schema R-S.
(c) a SQL query will not work if there are no 2. For r ÷ s to be defined, S ⊆ R
indexes on the relations 3. For r ÷ s to be defined, S ⊇ R
(d) None of these 4. The relation r ÷ s is a relation on schema
T7. Suppose that two relations R(A, B) and S(A, B) S-R.
have exactly the same schema. Consider the Which of above are true.
following equalities in relational algebra? (a) 1 and 3 (b) 2 and 4
(c) 1 and 2 (d) 3 and 4
1. R ∩ S = R – (R – S)
2. R ∩ S = S – (S – R) T11. Which of the following points are true
3. R ∩ S = R NATURAL-JOIN S 1. Tuple relational calculus is non-procedural.
4. R∩S=R×S 2. Declarative data manipulation language
Which of the equalities hold in relational algebra? require user to specify what data are needed
(a) 1 only (b) 1 and 2 only and specifying how to get those data.
(c) 1, 2 and 3 (d) 1, 2, 3 and 4 3. SQL is procedural DML.
© Copyright : www.madeeasypublications.org
Workbook 27
4. In a procedural language, the user instruct T14. Let the following relation schemas be given
© Copyright: Subject matter to MADE EASY Publications, New Delhi. No part of this book may be reproduced or utilised in any form without the written permission.
the system to perform a sequence of R = (A, B, C)
operation on the database to compute the S = (D, E, F)
desired result. Give an expression in the tuple relational
(a) 4 only (b) 3 and 2 calculus that is equivalent to each of following.
(c) 1 and 4 (d) 2, 3 and 4 (a) πA (r) (b) σB =17 (r)
(e) 1 and 2 (c) r × s (d) πA, F (σC = D (r × s))
T12. What will be the number of columns and rows T15. Consider the following database table named
respectively obtained for the operation A – B, if water_schemes:
A, B are Base union compatible and all the rows
water_schemes
of A are common to B? Assume A has 4 columns
and 20 rows; and B has 4 columns and 15 rows. scheme_no district_name capacity
© Copyright : www.madeeasypublications.org
Databases
© Copyright: Subject matter to MADE EASY Publications, New Delhi. No part of this book may be reproduced or utilised in any form without the written permission.
Ten (Key, pointer) pairs. As a function of n, the
number of records, How many blocks do we
need to hold a data file and a dense index.
Q.1 Which of the statement correct if maximum
13n 11n
possible key that can store in B tree node equal (a) (b)
30 30
to that of B+ tree node?
(a) B tree index nodes less than or equal B+ 10n n
tree index nodes for n keys. (c) (d)
30 3
(b) B+ tree index nodes less than or equal B
tree index nodes for n keys. Common Data for Q.5 & Q.6:
(c) I/O cost of B+ tree index less than or equal A DB table T1 has 2000 records and occupies 80 disk
I/O cost of B tree index for n keys. block. Another table T2 has 400 records and occupies
(d) Levels of B+ tree index less than or equal to 20 disk block. These two tables have to be jointed as
levels of B tree index for n keys. per a specified join condition that needs to be
evaluated for every pair of records from those two
Q.2 Suppose blocks hold either three records, or tables. The memory buffer space available can hold
Ten (Key, pointer) pairs. As a function of n, the exactly one block of record file for T1 and one block of
number of records, for dense index. How many records for T2 simultaneously at any point of time.
levels of index as is appropriate until the final
level of index has only one block? Q.5 If nested loop join algorithm is employed to
perform the join, with the most appropriate
n
(a) (b) Log3n choice of table to be used in order loop. The
3n number blocks access required for reading the
n data are
(c) (d) Log10n
4n (a) 8,00,000 (b) 40,080
(c) 32,020 (d) 100
Q.3 Order P is between 2 to P child pointers can
store in root node and between [P] to P child Q.6 If instead of nested loop join, block nested loop
pointers can store in other 2 nodes of B tree join is used, again with the most appropriate
index. How many maximum levels of index choice of table in the outer loop the reduction in
required to store 300 distinct keys in order (P) number block accesses required for reading the
5 B tree index? data will be
(a) 4 (b) 5 (a) 0 (b) 30,400
(c) 6 (d) 7 (c) 38,400 (d) 798,400
© Copyright : www.madeeasypublications.org
Workbook 29
Q.7 Consider a file of 16384 records. Each record is Q.11 Which of the following is correct?
© Copyright: Subject matter to MADE EASY Publications, New Delhi. No part of this book may be reproduced or utilised in any form without the written permission.
32 bytes long and its key fields of size 6 bytes. (a) B-trees are for storing data on disk and B+
The file is ordered on a non-key field, and the file trees are for main memory.
organization is unspanned. The file is stored in a (b) Range queries are faster on B+ trees.
file system with block size 1024 bytes, and the (c) B-trees are for primary indexes and B+ trees
size of a block pointer is 10 bytes. If the secondary are for secondary indexes.
index is built on the key field of the file, and a (d) The height of a B+ tree is independent of
multi-level index scheme is used to store the the number of records.
secondary index, the number of first-level and [GA TE-1999]
[GATE-1999]
second-level blocks in the multi-level index are Q.12 For given database file, if records physically
respectively ordered based on non key field (x) and index
(a) 8 and 0 (b) 128 and 6 build based on candidate key field (y ). Then
(c) 256 and 4 (d) 512 and 5 index said to be
[GA TE-2008]
[GATE-2008] (a) Primary index
(b) Clustering index
Q.8 Order P is maximum child pointers per B tree (c) Secondary index on key
node. (d) Secondary index on non-key
How many minimum levels of index required to
store 300 distinct keys in B tree with order P is Q.13 Which of the following statement false for B tree
5? and B+ tree index.
(a) 4 (b) 3 (a) B+ tree index faster for range queries
compare to B tree index.
(c) 5 (d) 2
(b) If disk block allocated for B+ tree index and
Q.9 For given database file, if records physically same size disk block allocated for B tree
ordered based on candidate key field x and non index then number of index blocks and I/O
key field (y ) used for index. Then index said to cost of B+ tree index loss than or equal to
be B tree index for given distinct keys.
(a) Primary index
(c) If disk block allocated for B+ tree index and
(b) Clustering index
same size disk block allocated for B tree
(c) Secondary index on key
index. Then B tree index access cost loss
(d) Secondary index on non-key
than or equal to B+ tree index for given
Q.10 Which statement is false? distinct keys.
(a) The leaf nodes of the B+ tree are usually (d) If number of keys that can store in B tree
linked together to provide ordered access and B+ tree index is same then I/O cost of
on the search field to the records. B tree index less than equal to I/O cost of
(b) Most implementations of dynamic multilevel B+ tree index for random access of some
index use a variation of the B tree data key from set of distinct keys.
structure called as B+ tree.
Q.14 A clustering index is defined on the fields which
(c) For a B+ tree constructed on a key, the
are of type
pointers in internal nodes are tree pointers
to blocks that are tree nodes. (a) Non-key and ordering
(d) In B+ tree, data pointers are stored in the (b) Non-key and non-ordering
leaf nodes of the tree and the structure of leaf (c) Key and ordering
nodes is same as that of the internal nodes. (d) Key and non-ordering
[GATE-2008]
[GATE-2008]
© Copyright : www.madeeasypublications.org
30 Data Science & Artificial Intelligence • Databases
Q.15 Consider file consist 65, 536 records. Each record Q.18 B+ trees are preferred to binary trees in databases
© Copyright: Subject matter to MADE EASY Publications, New Delhi. No part of this book may be reproduced or utilised in any form without the written permission.
32 byte long and its search key field size because
6 bytes. Disk block size 1024 bytes. Size of (a) Disk capacities are greater than memory
pointer 12 bytes. capacities
How many index blocks, levels of index, I/O (b) Disk access is much slower than memory
cost are required in worst case if access
(a) Index build on the key field (x) of the file (c) Disk data transfer rates are much less than
and records physically ordered based on memory data transfer rates
non key field (y)(y). (d) Disks are more reliable than memory
(b) Index build on the key field (x) of the file [GA TE-2000]
[GATE-2000]
and records physically ordered based on
Q.19 For given DB file, if records physically ordered
same key field (x) (x).
based on non key field (x) and index build on
(c) Index build on the non key field (x) of the
same non key field (x). Then index said to be
file and records physically ordered based
(a) Primary index
on same non key field (x) and every
(b) Clustering index
16 records whose non key field value same.
(c) Secondary index on key
(d) Index build on the non key field (x) if the
(d) Secondary index on non-key
file and records physically ordered based
on key field (y)
(y). Q.20 Choose the correct statements.
Q.16 Which one of the following is a key factor for (a) For fixed length records unspanned
preferring B+ trees to binary search trees for organization is preferred.
index database relations? (b) For variable length records unspanned
(a) Database relations have a large number of record organization is preferred.
(b) Database relations are sorted on the primary (c) For fixed length records spanned
key organization is preferred.
(c) B+ trees require less memory than binary (d) None of the above
search trees Q.21 For given database file, if records physically
(d) Data transfer from disks is in blocks ordered based on candidate key field (x) and
[GATE-2005]
[GATE-2005] field x used for index. The index said to be
Q.17 There are five records in a database. (a) Primary index
(b) Clustering index
Name Age Occupation Category (c) Secondary index on key
Rama 27 CON A (d) Secondary index on non-key
Abdul 22 ENG A
Jeniffer 28 DOC B
Maya 32 SER D
Dev 24 MUS C
There is an index file associated with this and it Q.22 In a database file structure, the search key field
contains the values 1, 3, 2, 5 and 4. Which one is 9 bytes long, the block size is 512 bytes, a
of the fields is the index built from? record pointer is 7 bytes and a block pointer is
(a) Age (b) Name 6 bytes. The largest possible order of a non-
(c) Occupation (d) Category leaf node in a B+ tree implementing this file
[GATE-1998]
[GATE-1998] structure is ________?
[GA TE IT
[GATE -2006]
IT-2006]
© Copyright : www.madeeasypublications.org
Workbook 31
Q.23 Given a system using unspanned blocking and Q.28 What will be the order (p) of a B+ tree with a
© Copyright: Subject matter to MADE EASY Publications, New Delhi. No part of this book may be reproduced or utilised in any form without the written permission.
100-byte blocks. A file contains records of 20, database of 5,00,000 records of 200 bytes each
50, 35, 70, 40, 20. and the search key is 15 bytes? Assume the
What percentage of space will be wasted in the tree and data pointers are 5 bytes each and the
blocks allocated for the file? index node (data block size) is 1024 bytes.
Q.24 A B+ tree index is to be built on the Name Q.29 A B+-Tree of order d is a tree in which each
attribute of the relation STUDENT. Assume that internal node has between d and 2d keys
all student names are of length 8 bytes, disk values.
block are size 512 bytes, and index pointer are The root has between 1 and 2d keys values
of size 4 bytes. Given this scenario, what would what is the maximum number of internal nodes
be the best choice of the degree (i.e. the number in a B+ -Tree of order 4 with 52 leaves.
of pointers per node) of the B+ tree?
[GA TE-2002]
[GATE-2002] Q.30 The order of an internal node in a B+ tree index
is the maximum number of children it can have.
Q.25 Suppose we have a block-addressable disk Suppose that a child pointer takes 6 bytes, the
drive. With such block-organized disk non-data search field value takes 14 bytes, and the block
overhead of subblocks and interblock gaps have size is 512 bytes. What is the order of the internal
to be accounted for. There are 40000 bytes per node?
track and the amount of space taken up by [GA TE-2004]
[GATE-2004]
subblocks and interblocks gaps equivalent to
250 bytes per block. A file contains records and Q.31 Assume that you have built a dense primary B+-
record size is 200 bytes to be stored on the disk. Tree indeed on a file containing 20,000 records.
If a total of 32 blocks can be stored per track The key field for this B +-Tree indeed is a
then what is the blocking factor? The term 40 byte string and it is a candidate key. Pointers
“blocking factor” is used to indicate the number are at 10 bytes. The size of one disk page is
of records that are to the stored in each block in 1000 bytes. The index was built in a bottom-up
a file. A block is organised to hold an integral fashion using the bulk-loading algorithm and
number of logical records. nodes were filled up as much as possible. How
many levels of indexing is required?
Q.26 Consider a B + tree in which the maximum
number of keys in a node is 5. What is the Q.32 The order of a leaf node in a B+ tree is the
minimum number of keys in any non-root maximum number of (value, data record pointer)
node? [GATE-2010]
[GATE-2010] pairs it can hold. Given that the block size is
1 K bytes, data record pointers is 7 bytes long,
Q.27 Consider a table T in a relational database with a
the value field is 9 bytes long and a block pointer
key field K. AB tree of order p is used as an
is 6 bytes long, what is the order of the leaf
access structure on K, where p denotes the
node?
maximum number of tree pointers in a B tree
[GATE-2007]
[GATE-2007]
node. Assume that K is 10 bytes long; disk block
size is 512 bytes; each data pointer PD is 8 bytes Q.33 Assume block size 4096 bytes, size of key is
long and each block pointer PB is 5 bytes long. 4 bytes. Size of pointer be 8 bytes. How many
In order for each B tree node to fit in a single keys are possible per blocks for B +-Tree
disk block, the maximum value of p is ________. organization?
[GATE IT
[GATE -2004]
IT-2004]
© Copyright : www.madeeasypublications.org
32 Data Science & Artificial Intelligence • Databases
Q.34 The following key values are inserted into a Q.37 A file consists of records of size 64 bytes each
© Copyright: Subject matter to MADE EASY Publications, New Delhi. No part of this book may be reproduced or utilised in any form without the written permission.
B+ -Tree in which order of the internal nodes is 3 including key field of size 14 bytes. An address
and that of the leaf nodes is 2, in the sequence of a disk block takes 2 bytes. Assume the disk
given below. The order of internal nodes is the block size is 512 bytes and there are 16 K
maximum number of tree pointers in each node, records then which of the following is true?
and the order of leaf nodes is the maximum (a) Blocking factor of record file is 8.
number of data items that can be stored in it. (b) Blocking factor of index file is 24.
The B+ - Tree is initially empty. (c) Number of blocks in the first level is 64.
(d) Number of blocks in the second level index
10, 3, 6, 8, 4, 2, 1
is 10.
The maximum number of times leaf nodes would
Q.38 Which of the following is/are correct?
get split up as a result of these insertions is
(a) In a Dense clustering index, the index record
[GA TE-2009]
[GATE-2009]
contains the search-key value and a pointer
to the first data record with that search-key
value and the rest of the records will be in
the sequential pointers.
(b) In a Sparse clustering index, the index
record contains the search-key value and a
Q.35 Which of the following is/are correct?
pointer to the first data record with that
(a) In ordered indices the file containing the search-key value and the rest of the records
records is sequentially ordered, a Clustered will be in the sequential pointers.
index is an index whose search key also (c) In Sparse the indices values are larger, index
defines the sequential order of the file. is created for these values of the index. This
(b) In ordered indices the file containing the is called multilevel index.
records is sequentially ordered, a Non (d) In Sparse the indices values are larger, index
clustered is an index whose search key also is created for these values of the index. This
defines the sequential order of the file. is called Sequential index.
(c) Indices whose search key specifies an order
Q.39 Consider a file of 16384 records where each
different from the sequential order of the file
records are 32 bytes long and its key field is of
are called Non-clustered indices.
6 bytes. The file is ordered on a non-key field
(d) Indices whose search key specifies an order
and the file organization is unspanned. The file
different from the sequential order of the file
is stored in a file system with block size
are called Secondary indices.
1024 bytes and size of a block pointer is
Q.36 Which of the following is a key factor for preferring 10 bytes. If the secondary index is built on the
B+ trees to binary search trees for indexing key field of the file and a multi-level index
database relations? scheme is used to store the secondary index.
(a) Database relations have a large number of Which of the following is correct?
records. (a) The number of blocks in the first level will
be 512.
(b) Database relations are sorted on the primary
(b) The number of blocks in the first level will
key.
be 256.
(c) B+ trees require more memory than binary
(c) The number of blocks in the second level in
search trees.
the multi-level index will be 4.
(d) Data transfer from disks is in blocks.
(d) The number of blocks in the second level is 9.
© Copyright : www.madeeasypublications.org
Workbook 33
T4. With respect to the B+ tree index method select
© Copyright: Subject matter to MADE EASY Publications, New Delhi. No part of this book may be reproduced or utilised in any form without the written permission.
the true statements
(a) Records are physically stored in primary
key order
(b) B+ tree uses a hashing algorithm
T1. Consider file consist of 10,000 record. Block size
(c) The index tree may or may not become
1024 bytes, record size 100 bytes. Search key
unbalanced as a result of updates
size 9 bytes, pointer 7 bytes. (d) None of the above
(a) How many 1st level index blocks using
dense index. T5. A B-tree used as an index for a large database
(b) How many 1st level index blocks using of table has four levels including the root node. If
sparse index. a new key 18 inserted in this index, then the
(c) How many levels of index required if 1st level maximum number of nodes that could be newly
created in the process are
dense index.
(a) 3 (b) 4
(d) How many levels of index required if 1st level
(c) 5 (d) 2
sparse index.
T6. A data dictionary doesn’t provide information
T2. Consider a file consist 30,000 fixed length
about
records of size 100 bytes. Each disk block size
(a) where data is located
is 1024 bytes, block pointer size 6 bytes. Search
(b) the size of the disk storage
key size 9 bytes.
(c) who owns the data
(a) How many 1st level index blocks using
(d) how data is used
dense index?
T7. B+ Trees are considered BALANCED because
(b) How many 1st level index blocks using
(a) the lengths of the paths from the root to all
sparse index.
leaf nodes are all equal.
(c) How many levels of index required if 1st level
(b) the lengths of the paths from the root to all
uses dense index.
leaf nodes differ from each other by atmost 1.
(d) How many levels of index required if 1st level
(c) the number of children of any two non-leaf
uses sparse index.
sibling nodes differ by at most 1.
T3. DB file consist 1250 records. Block can hold (d) the number of records in any two leaf nodes
either 3 records or (10 keys, 11 pointers) differ by at most 1.
(a) How many minimum index blocks and [GA TE-2016, Ans : (a)]
[GATE-2016,
minimum levels of index required. Dense T8. Find the minimum number of elements (keys)
B+ tree index for above DB file. that need to be inserted into a B+ tree with the
(b) How many maximum index blocks and order of internal node 3[maximum child pointers
maximum levels if index required for dense per node] and leaf node 2[maximum keys per
B+ tree. Index for above DB file. node], to make it to reach 3 levels?
(c) How many min index blocks and min levels [Ans : (7)]
of index required for sparse B+ tree index
T9. Suppose size of block 1000 bytes search key
for above DB file.
of 12 bytes, pointer size 8 bytes. How many
(d) How many max index blocks and max levels
maximum records in DB file which can index by
of index required for sparse B+ tree. Index
dense B+ tree of 2 levels?
for above DB file.
© Copyright : www.madeeasypublications.org
34 Data Science & Artificial Intelligence • Databases
(a) 1200 (b) 1250 How many max index blocks required if node
© Copyright: Subject matter to MADE EASY Publications, New Delhi. No part of this book may be reproduced or utilised in any form without the written permission.
(c) 15000 (d) 2499
P
[Ans : (d)] order P is defined as between to P pointers
2
T10. DB file consist 50000 records with record size per node?
100 byte block size 512 bytes. If sparse B+
(a) 1635 (b) 1631
tree index build over given DB file with search
(c) 716 (d) 713
key size 20 bytes both block pointer and record
pointer sizes 12 bytes each. [Ans : (b)]
© Copyright : www.madeeasypublications.org