DBMS Question Bank - Unit 2
DBMS Question Bank - Unit 2
UNIT-II
PART-A
1. What is functional dependency? Give example. (CO2) (APR/MAY 2023, NOV/DEC 2023)
Functional dependency is a relationship that exists when one attribute uniquely determines
another attribute. It R is a relation with attributes X and Y, a functional dependency between the
attributes is represented as X->Y, which specifies Y is functionally dependent on X. Functional
Dependency (FD) is a set of constraints between two attributes in a relation.
Example
Let's take an example of a student entity only. Let's assume it has attributes such as roll number,
name, and DOB as shown in the figure.
If we take another attribute which is age, we can derive it from the DOB attribute. Age need not
be present in the database. Derived attributes are represented with the dotted ellipse as shown in
the figure.
8. What is the significance of “participation role name” in the description of relationship types?
(CO2) (NOV/DEC 2019)
The Participation role is the part that every entity participates in a relationship. This role is
important to use role name in the depiction of relationship type when the similar entity type participates
more than once in a relationship type in various roles. The role names are necessary in recursive
relationships.
10. What are the problems caused by redundancy? (CO2) (APR/MAY, 2018)
Problems caused by Redundancy: Following problems can be caused by
redundancy
i) Redundant Storage: Some information is stored repeatedly.
ii) Update Anomalies: If one copy of such repeated data is updated then
inconsistency is created unless all other copies are similarly updated.
iii) Insertion Anomalies: Due to insertion of new record repeated information get
added to the relation schema.
iv) Deletion Anomalies: Due to deletion of particular record some other important
information associated with the deleted record get deleted and thus we may lose
Isbom some other important information from the schema.
13. Differentiate Loss less join decomposition and Lossy Join decomposition.
(CO2) (NOV/DEC, 2019)
Lossless Join Dependency Lossy Join Dependency
It means that whenever the join : In this type of join dependency, data
occurs between the tables, then no loss may occur at some point in time
information should be lost, the new which includes the absence of a tuple
table must have all the content in the from the original table or duplicate
original table. tuples within the database.
15. Why certain functional dependencies are called trivial functional dependencies?
(CO2) (NOV/DEC 2014)
A functional dependency FD: XY is called trivial if Y is a subset of X. This kind of dependency
is called trivial because it can be derived from common sense. If one "side" is a subset of the other, it's
considered trivial. The left side is considered the determinant and the right the dependent.
For example - {A, B} B is a trivial functional dependency because B is a subset of A,B. Since
(A, B) -> B includes B, the value of B can be determined. It's a trivial functional dependency because
determining B is satisfied by its relationship to A, B.
17. Give an example of a relation schema R and set of dependencies such that R is in BCNF but
not in 4NF. (CO2) (APR/MAY 2017)
Consider relation R (A, B, C, D) with dependencies
AB→C
ABC→D
AC→B
Here the only key is AB. Thus each functional dependency has super key on the left. But MVD
has non-super key on its left. So it is not 4NF.
18. Give an example for a weak and a strong entity. (CO2) (APR/MAY 2024)
Strong Entity: A Strong Entity is a type of entity that has a key Attribute. Strong Entity does not
depend on other Entity in the Schema. It has a primary key that helps in identifying it uniquely and it is
represented by a rectangle. These are called Strong Entity Types.
Example:
Strong entity set always has a primary key. It does not have enough attributes to build a primary
key. It is represented by a rectangle symbol.
Weak Entity: An Entity type has a key attribute that uniquely identifies each entity in the entity
set. But some entity type exists for which key attributes can’t be defined. These are called Weak Entity
types.
Example:
A bank account cannot be uniquely identified without knowing the bank to which the account
belongs, so bank account is a weak entity.
19. Draw the symbols used in an entity relationship diagram for repersenting an entity set, weak
entity set, attributes and multivalued attribute. (CO2) (NOV/DEC 2021)
Attributes are the properties that define the entity type. For example, Roll_No, Name, DOB,
Age, Address, and Mobile_No are the attributes that define entity type Student.
In ER diagram,
Entity set is represented by rectangle
20. For a binary relationship set R between entity sets A and B, list the mapping cardinalities.
(CO2) (NOV/DEC, 2021)
For a binary relationship set R between entity sets A and B, the Mapping Cardinality is ONE TO
ONE if an entity in A is associated with at most one entity in B, and an entity in B is associated with at
most one entity in A
PART-B
Example - Employee
SSN Name JobType DeptName
557-78-6587 Lance Smith Accountant Salary
214-45-2398 Lance Smith Engineer Product
Name is functionally dependent on SSN because an employee‘s name can be uniquely determined
from their SSN. Name does not determine SSN, because more than one employee can have the same
name.
Keys
Whereas a key is a set of attributes that uniquely identifies an entire tuple, a functional dependency
allows us to express constraints that uniquely identify the values of certain attributes.
However, a candidate key is always a determinant, but a determinant doesn‘t need to be a key.
Axioms
Before we can determine the closure of the relation, Student, we need a set of rules.
i. Reflexivity Rule
ii. Augmentation Rule
iii. Transitivity Rule
iv. Union Rule
v. Decomposition Rule
vi. Pseudo transitivity Rule
2. Elaborate on first normal form, second normal form and third normal form with examples.
(CO2) (APR/MAY, 2023)
Normalization of Database Database
Normalisation is a technique of organizing the data in the database. Normalization is a systematic
approach of decomposing tables to eliminate data redundancy and undesirable characteristics like
Insertion, Update and Deletion Anamolies. It is a multi-step process that puts data into tabular form by
removing duplicated data from the relation tables.
The Primary key is usually a single column, but sometimes more than one column can be
combined to create a single primary key. For example consider a table which is not in First normal form.
Example: - Student Table :
In First Normal Form, any row must not have a column in which more than one value is saved,
like separated with commas. Rather than that, we must separate such data into multiple rows.
Student Table following 1NF will be:
Using the First Normal Form, data redundancy increases, as there will be many columns with
same data in multiple rows but each row as a whole will be unique.
In example of First Normal Form there are two rows for Adam, to include multiple subjects that
he has opted for. While this is searchable, and follows First normal form, it is an inefficient use of space.
Also in the above Table in First Normal Form, while the candidate key is {Student, Subject}, Age of
Student only depends on Student column, which is incorrect as per Second Normal Form. To achieve
second normal form, it would be helpful to split out the subjects into an independent table, and match
them up using the student names as foreign keys.
New Student Table following 2NF will be:
Student Age Age
Adam 15
Alex 14
Stuart 17
In Student Table the candidate key will be Student column, because all other column i.e Age is
dependent on it.
New Subject Table introduced for 2NF will be:
Student Age Subject
Adam Biology
Adam Maths
Alex Maths
Stuart Maths
In Subject Table the candidate key will be {Student, Subject} column. Now, both the above
tables qualify for Second Normal Form and will never suffer from Update Anomalies. Although there
are a few complex cases in which table in Second Normal Form suffers Update Anomalies, and to
handle those scenarios Third Normal Form is there.
Student_Detail Table:
In this table Student_id is Primary key, but street, city and state depends upon Zip. The
dependency between zip and other fields is called transitive dependency. Hence to apply 3NF, we need
to move the street, city and state to new table, with Zip as primary key.
New Student_Detail Table:
Student_id Student_name DOB Zip
Address Table:
Street city State Zip
3. Explain with suitable example, the constraints of specialization and generalization in ER data
modeling. (CO2) (NOV/DEC 2019)
The ER Model has the power of expressing database entities in a conceptual hierarchical manner.
As the hierarchy goes up, it generalizes the view of entities, and as we go deep in the hierarchy, it gives
us the detail of every entity included.
Going up in this structure is called generalization, where entities are clubbed together to
represent a more generalized view. For example, a particular student named Mira can be generalized
along with all the students. The entity shall be a student, and further, the student is a person. The reverse
is called specialization where a person is a student, and that student is Mira.
Generalization:
As mentioned above, the process of generalizing entities, where the generalized entities contain
the properties of all the generalized entities is called generalization. In generalization, a number of
entities are brought together into one generalized entity based on their similar characteristics. For
example, pigeon, house sparrow, crow and dove can all be generalized as Birds.
Similarly, in a school database, persons can be specialized as teacher, student, or a staff, based
on what role they play in school as entities.
Inheritance :
We use all the above features of ER-Model in order to create classes of objects in object-oriented
programming. The details of entities are generally hidden from the user; this process known as
abstraction. Inheritance is an important feature of Generalization and Specialization. It allows lower-
level entities to inherit the attributes of higher-level entities.
For example, the attributes of a Person class such as name, age, and gender can be inherited by
lower-level entities such as Student or Teacher.
4. Explain Boyce Codd normal form, fourth normal form and fifth normal form with examples.
(CO2) (APR/MAY, 2023)
Boyce and Codd Normal Form is a higher version of the Third Normal form. This form deals
with certain type of anomaly that is not handled by 3NF. A 3NF table which does not have multiple
overlapping candidate keys is said to be in BCNF. For a table to be in BCNF, following conditions must
be satisfied:
R must be in 3rd Normal Form and, for each functional dependency ( X -> Y ), X should be a
super Key.
Consider the following relationship: R(A , B, C, D) and following dependencies:
ABCD
BC AD
DB
This relationship is already in 3rd Normal form. Keys are A and BC.
Hence, in the functional dependency, ABCD, A is the super key.
In second relation, BCAD, BC is also a key, but in, DB, D is not a key.
Hence we can break our relationship R into two relationships R1 and R2.
A(A, B, C, D)
R1(A, D, C) R2(D,B)
Breaking table into two tables, one with A,D and C while the other with D and B.
Fourth Normal Form(4NF):
It should meet all the requirement of 3NF
Attribute of one or more rows in the table should not result in more than one rows of the same
table leading to multi-valued dependencies
To understand it clearly, consider a table with Subject, Lecturer who teaches each subject and
recommended Books for each subject.
COURSE
SUBJECT
LECTURER
BOOKS
If we observe the data in the table above it satisfies 3NF. But LECTURER and BOOKS are two
independent entities here. There is no relationship between Lecturer and Books. In the above example,
either Alex or Bosco can teach Maths. For Maths subject , student can refer either 'Maths Book1' or
'Maths Book2'.
That is,
SUBJECT --> LECTURER
SUBJECT-->BOOKS
This is a multivalued dependency on SUBJECT. If we need to select both lecturer and books
recommended for any of the subject, it will show up (lecturer, books) combination, which implies lecturer
who recommends which book. This is not correct.
SELECT c.LECTURER, c.BOOKS FROM COURSE c WHERE SUBJECT = 'Maths';
To eliminate this dependency, we divide the table into two as below
COURSE_LECTURER COURSE_BOOKS
SUBJECT SUBJECT
LECTURER BOOKS
4NF
SUBJECT LECTURER SUBJECT BOOKS
Maths Alex Maths Maths Book 1
Maths Boscoo Maths Maths Book 2
Physics Rose Physics Physics Book
Chemistry Adam Chemistry Chemistry Book
Now if we want to know the lecturer names and books recommended for any of the subject, we
will fire two independent queries. Hence it removes the multi-valued dependency and confusion around
the data. Thus the table is in 4NF.
COURSE
SUBJECT
LECTURER
CLASS
In above table, Rose takes both Mathematics and Physics class for Semester 1, but she does not
take Physics class for Semester 2. In this case, combination of all these 3 fields is required to identify a
valid data. Imagine we want to add a new class - Semester3 but do not know which Subject and who will
be taking that subject. We would be simply inserting a new entry with Class as Semester3 and leaving
Lecturer and subject as NULL. As we discussed above, it's not a good to have such entries. Moreover, all
the three columns together act as a primary key, we cannot leave other two columns blank.
Hence we have to decompose the table in such a way that it satisfies all the rules till 4NF and
when join them by using keys, it should yield correct record. Here, we can represent each lecturer's
Subject area and their classes in a better way. We can divide above table into three - (SUBJECT,
LECTURER), (LECTURER, CLASS), (SUBJECT, CLASS)
5NF
SUBJECT LECTURER CLASS LECTURER CLASS SUBJECT
Maths Alex SEMESTER 1 Alex SEMESTER 1 Maths
Maths Boscoo SEMESTER 1 Boscoo SEMESTER 1 Maths
Physics Rose SEMESTER 1 Rose SEMESTER 1 Physics
Chemistry Adam SEMESTER 1 Adam SEMESTER 1 Chemistry
Now, each of combinations is in three different tables. If we need to identify who is teaching
which subject to which semester, we need join the keys of each table and get the result.
5. Construct an E-R diagram for a car-insurance company whose customers own one or more
cars each. Each car has associated with it zero to any number of recorded accidents. Each
insurance policy covers one or more cars, and has one or more premium payments associated
with it. Each payment is for a particular period of time, and has an associated due date, and
the date when the payment was received. (CO2) (APR/MAY 2022, NOV/DEC 2023)
Entity Relationship Diagram – An Entity–relationship model (ER model) describes the structure of
a database with the help of a diagram, which is known as Entity Relationship Diagram. An ER
model is a design or blueprint of a database that can later be implemented as a database.
Functional dependency
Functional dependency is a relationship that exists when one attribute uniquely determines
another attribute. It R is a relation with attributes X and Y, a functional dependency between the
attributes is represented as X->Y, which specifies Y is functionally dependent on X. Functional
Dependency (FD) is a set of constraints between two attributes in a relation.
Book is not in BCNF because Catalog_no is not a key and there is a functional dependency
“Catalog_no –> Title Author Publisher Year”.
Book is not in 3NF because non-prime attributes (Publisher Year) are transitively dependent on
key [Title, Author]. Book is in 2NF because every non-prime attribute of the table is either dependent
on the whole of a candidate key [Title, Author], or on another non prime attribute.
7. A university registrar’s office maintains data about the following entities: (i) courses,
including number, title, credits, syllabus, and prerequisites; (ii) course offerings, including
course number, year, semester, section number, instructor(s), timings, and classroom; (iii)
students, including student-id, name, and program; and (iv)instructors, including
identification number, name, department, and title. Further, the enrollment of students in
courses and grades awarded to students in each course they are enrolled for must be
appropriately modeled. Construct an E-R diagram for the registrar’s office. Document all
assumptions that you make about the mapping constraints.
(CO2) (NOV/DEC 2021, APR/MAY, 2023)
8. Consider the following case study describing the academic functioning of a college.
A college has many departments.
A department would have many students as well as employs many faculty members
A student can register into various courses; similarly a course can be registered by
many students
A student lives in a single hostel but a hostel accommodates many students
9. i). Give suitable example for multivalued dependencies and Join dependencies.
(CO2) (NOV/DEC 2022)
Multivalued dependency
Multivalued dependency occurs when two attributes in a table are independent of each other but,
both depend on a third attribute. A multivalued dependency consists of at least two attributes that are
dependent on a third attribute that's why it always requires at least three attributes. Mutiivalued
dependencies are consequences of 1NF which did not allow an attribute in a tuple to have a set of
values. In a relation, the functional dependency A -> B relates a value of A to a value of B while
multivalued dependency represented A -> B represents a relationship that defines a relationship in
which attribute B are determined by a single value of A. The multivalued dependency is the result of
1NF that prohibits an attribute from having a set of values.
Example: Suppose there is a bike manufacturer company which produces two colors(white and
black) of each model every year.
BIKE_MODEL MANUF_YEAR COLOR
M2011 2008 White
M2001 2008 Black
M3001 2013 White
M3001 2013 Black
M4006 2017 White
M4006 2017 Black
Here columns COLOR and MANUF_YEAR are dependent on BIKE_MODEL and independent
of each other. In this case, these two columns can be called as multivalued dependent on
BIKE_MODEL. The representation of these dependencies is shown below:
BIKE_MODEL → → MANUF_YEAR
BIKE_MODEL → → COLOR
Join Dependency
Join decomposition is a further generalization of Multivalued dependencies. If the join of R1 and
R2 over C is equal to relation R, then we can say that a join dependency (JD) exists, where R1 and R2
are the decompositions R1(A, B, C) and R2(C, D) of a given relations R (A, B, C, D).
Alternatively, R1 and R2 are a lossless decomposition of R.
A JD ⋈ {R1, R2,..., Rn} is said to hold over a relation R if R1, R2,....., Rn is a lossless-join
decomposition.
The *(A, B, C, D), (C, D) will be a JD of R if the join of join's attribute is equal to the relation R.
Here, *(R1, R2, R3) is used to indicate that relation R1, R2, R3 and so on are a JD of R.
ii). Compare and contrast 1NF, 2NF and 3NF with suitable example. (CO2) (NOV/DEC 2022)
In order to be in 3NF
In order to be in 1NF any In order to be there should be no
relation must be atomic and in 2NF any relation transitive dependency
should not contain any must be in 1NF and that is no non-prime
composite or multi-valued should not contain any attribute should be
attributes. partial dependency. transitively dependent
on the candidate key.
The main goal of first normal The main goal of The goal of the third
form is to eliminate the second normal form is normal form is to
redundant data within the to actually ensure the ensure referential
table. data dependencies. integrity.
10. (i). Construct an E-R diagram for a hospital with a set of patients and a set of medical
doctors, Associate with each patient a log of the various tests and examinations conducted.
(CO2) (APR/MAY, 2024)
Answer:
(ii) Draw an ER diagram for the airport database. Be sure to indicate the various attribute of
each entity and relationship set; also specify the key and participation constraints for each
relationship set. Specify any necessary overlap and covering constraints as well.
(CO2) (APR/MAY, 2024)
Answer: