0% found this document useful (0 votes)
49 views

Cse & It Interview Questions: 1. What Is Normalization? Why Is It Needed? Ans

The document provides information about database normalization and different normal forms. It defines normalization as organizing data to minimize redundancy. The goals of normalization are to isolate data and avoid anomalies like insertion, deletion, and modification anomalies. It then discusses the different normal forms - first normal form requires each attribute contain atomic values, second normal form requires non-key attributes depend on whole primary key, and third normal form removes non-key attributes that depend on other non-prime attributes. Higher normal forms like BCNF, fourth, and fifth are also covered briefly. Finally, it differentiates between database keys like super keys, candidate keys, and primary keys - with super keys being any set of attributes that uniquely identify a record,

Uploaded by

Er Santosh Kumar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views

Cse & It Interview Questions: 1. What Is Normalization? Why Is It Needed? Ans

The document provides information about database normalization and different normal forms. It defines normalization as organizing data to minimize redundancy. The goals of normalization are to isolate data and avoid anomalies like insertion, deletion, and modification anomalies. It then discusses the different normal forms - first normal form requires each attribute contain atomic values, second normal form requires non-key attributes depend on whole primary key, and third normal form removes non-key attributes that depend on other non-prime attributes. Higher normal forms like BCNF, fourth, and fifth are also covered briefly. Finally, it differentiates between database keys like super keys, candidate keys, and primary keys - with super keys being any set of attributes that uniquely identify a record,

Uploaded by

Er Santosh Kumar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

CSE & IT INTERVIEW QUESTIONS

DBMS:
1. What is normalization? Why is it needed?

Ans: the process of organizing data to minimize redundancy is called normalization.

The goal of database normalization is to decompose relations with anomalies in order to produce
smaller, well-structured relations. Normalization usually involves dividing large, badly-formed
tables into smaller, well-formed tables and defining relationships between them. The objective is
to isolate data so that additions, deletions, and modifications of a field can be made in just one
table and then propagated through the rest of the database via the defined relationships.

Edgar F. Codd, the inventor of the relational model, introduced the concept of normalization and
what we now know as the First Normal Form (1NF) in 1970.[1] Codd went on to define the
Second Normal Form (2NF) and Third Normal Form (3NF) in 1971,[2] and Codd and Raymond
F. Boyce defined the Boyce-Codd Normal Form (BCNF) in 1974.[3] Higher normal forms were
defined by other theorists in subsequent years, the most recent being the Sixth normal form
(6NF) introduced by Chris Date, Hugh Darwen, and Nikos Lorentzos in 2002.[4]

Informally, a relational database table (the computerized representation of a relation) is often


described as "normalized" if it is in the Third Normal Form.[5] Most 3NF tables are free of
insertion, update, and deletion anomalies, i.e. in most cases 3NF tables adhere to BCNF, 4NF,
and 5NF (but typically not 6NF).

A standard piece of database design guidance is that the designer should create a fully
normalized design; selective denormalization can subsequently be performed for performance
reasons.[6] However, some modeling disciplines, such as the dimensional modeling approach to
data warehouse design, explicitly recommend non-normalized designs, i.e. designs that in large
part do not adhere to 3NF.[7]

2. What are insertion, deletion, & modification anomalies?


Ans:
3. What is first, second, or third normal forms?
Ans: First Normal Form:
===============
Tables are said to be in first normal form when:
- The table has a primary key.
- No single attribute (column) has multiple values.
- The non-key attributes (columns) depend on the primary key.
Some examples of placing a table in first normal form are:

author_id: stories:
000024 novelist, playwright // multiple
values
000034 magazine columnist
002345 novella, newpaper columnist // multiple
values

In first normal form the table would look like:

author_id: stories:
000024 novelist
000024 playwright
000034 magazine columnist
002345 novella
002345 newpaper columnist

Second Normal Form:


=================
Tables are said to be in second normal form when:
- The tables meet the criteria for first normal form.
- If the primary key is a composite of attributes (contains multiple
columns), the non key attributes (columns) must depend on the whole
key.

Note: Any table with a primay key that is composed of a single


attribute (column) is automatically in second normal form.

Third Normal Form:


================
Tables are said to be in third normal form when:
- The tables meet the criteria for second normal form.
- Each non-key attribute in a row does not depend on the entry in
another key column.

Fourth Normal Form:


================
Tables are said to be in fourth normal form when:
- The table meets the criteria for third normal form.
- Situations where non-key attributes depend on the key column
exclusive of other non-key columns are eliminated.

Fifth Normal Form:


===============
Tables are said to be in fifth normal form when:
- The table meets the criteria for fourth normal form.
- The table consists of a key attribute and a non-key attribute only.

 
Name Description
First Normal Form An entity is in First Normal Form (1NF) when all tables are two-dimensional with no
repeating groups.
A row is in first normal form (1NF) if all underlying domains contain atomic values
only. 1NF eliminates repeating groups by putting each into a separate table and
connecting them with a one-to-many relationship. Make a separate table for each
set of related attributes and uniquely identify each record with a primary key.

 Eliminate duplicative columns from the same table.


 Create separate tables for each group of related data and identify each row
with a unique column or set of columns (the primary key).

An entity is in Second Normal Form (2NF) when it meets the requirement of being
in First Normal Form (1NF) and additionally:

 Does not have a composite primary key. Meaning that the primary key can
not be subdivided into separate logical entities.
 All the non-key columns are functionally dependent on the entire primary
Second Normal key.
Form  A row is in second normal form if, and only if, it is in first normal form and
every non-key attribute is fully dependent on the key.
 2NF eliminates functional dependencies on a partial key by putting the
fields in a separate table from those that are dependent on the whole key.
An example is resolving many:many relationships using an intersecting
entity.

An entity is in Third Normal Form (3NF) when it meets the requirement of being in
Second Normal Form (2NF) and additionally:

 Functional dependencies on non-key fields are eliminated by putting them


in a separate table. At this level, all non-key fields are dependent on the
Third Normal Form
primary key.
 A row is in third normal form if and only if it is in second normal form and if
attributes that do not contribute to a description of the primary key are
move into a separate table. An example is creating look-up tables.

Boyce Codd Normal Form (BCNF) is a further refinement of 3NF. In his later
writings Codd refers to BCNF as 3NF. A row is in Boyce Codd normal form if, and
only if, every determinant is a candidate key. Most entities in 3NF are already in
BCNF.
Boyce-Codd Normal
Form BCNF covers very specific situations where 3NF misses inter-dependencies
between non-key (but candidate key) attributes. Typically, any relation that is in
3NF is also in BCNF. However, a 3NF relation won't be in BCNF if (a) there are
multiple candidate keys, (b) the keys are composed of multiple attributes, and (c)
there are common attributes between the keys.
Fourth Normal Form An entity is in Fourth Normal Form (4NF) when it meets the requirement of being in
Third Normal Form (3NF) and additionally:

 Has no multiple sets of multi-valued dependencies. In other words, 4NF


states that no entity can have more than a single one-to-many relationship
within an entity if the one-to-many attributes are independent of each other.
 Many:many relationships are resolved independently.

An entity is in Fifth Normal Form (5NF) if, and only if, it is in 4NF and every join
Fifth Normal Form
dependency for the entity is a consequence of its candidate keys.

4. Do you implement it in your project, how explain with example?


5. What is super key, a key, candidate key, primary key or minimal super key
etc?
Ans: DBMS Keys
A key is an attribute (also known as column or field) or a combination of attribute that is used to identify records.
Sometimes we might have to retrieve data from more than one table, in those cases we require to join tables with
the help of keys. The purpose of the key is to bind data together across tables without repeating all of the data in
every table.

The various types of key with e.g. in SQL are mentioned below, (For examples let suppose we have an Employee
Table with attributes ‘ID’ , ‘Name’ ,’Address’ , ‘Department_ID’ ,’Salary’)

(I) Super Key – An attribute or a combination of attribute that is used to identify the records uniquely is known as
Super Key. A table can have many Super Keys.
E.g. of Super Key
1 ID
2 ID, Name
3 ID, Address
4 ID, Department_ID
5 ID, Salary
6 Name, Address
7 Name, Address, Department_ID ………… So on as any combination which can identify the records uniquely will be
a Super Key.

(II) Candidate Key – It can be defined as minimal Super Key or irreducible Super Key. In other words an attribute
or a combination of attribute that identifies the record uniquely but none of its proper subsets can identify the
records uniquely.
E.g. of Candidate Key
1 Code
2 Name, Address
For above table we have only two Candidate Keys (i.e. Irreducible Super Key) used to identify the records from the
table uniquely. Code Key can identify the record uniquely and similarly combination of Name and Address can
identify the record uniquely, but neither Name nor Address can be used to identify the records uniquely as it might
be possible that we have two employees with similar name or two employees from the same house.

(III) Primary Key – A Candidate Key that is used by the database designer for unique identification of each row in
a table is known as Primary Key. A Primary Key can consist of one or more attributes of a table.
E.g. of Primary Key - Database designer can use one of the Candidate Key as a Primary Key. In this case we have
“Code” and “Name, Address” as Candidate Key, we will consider “Code” Key as a Primary Key as the other key is
the combination of more than one attribute.
(IV) Foreign Key – A foreign key is an attribute or combination of attribute in one base table that points to the
candidate key (generally it is the primary key) of another table. The purpose of the foreign key is to ensure
referential integrity of the data i.e. only values that are supposed to appear in the database are permitted.
E.g. of Foreign Key – Let consider we have another table i.e. Department Table with Attributes “Department_ID”,
“Department_Name”, “Manager_ID”, ”Location_ID” with Department_ID as an Primary Key. Now the
Department_ID attribute of Employee Table (dependent or child table) can be defined as the Foreign Key as it can
reference to the Department_ID attribute of the Departments table (the referenced or parent table), a Foreign Key
value must match an existing value in the parent table or be NULL.

(V) Composite Key – If we use multiple attributes to create a Primary Key then that Primary Key is called
Composite Key (also called a Compound Key or Concatenated Key).
E.g. of Composite Key, if we have used “Name, Address” as a Primary Key then it will be our Composite Key.

(VI) Alternate Key – Alternate Key can be any of the Candidate Keys except for the Primary Key.
E.g. of Alternate Key is “Name, Address” as it is the only other Candidate Key which is not a Primary Key.

(VII) Secondary Key – The attributes that are not even the Super Key but can be still used for identification of
records (not unique) are known as Secondary Key.
E.g. of Secondary Key can be Name, Address, Salary, Department_ID etc. as they can identify the records but they
might not be unique.
6. What is entity integrity, referential integrity etc?

You might also like