Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

1

Explain the 2 NF
Normalization is the process of organizing the data in the database.
Normalization is used to minimize the redundancy from a relation or set of relations. It is
also Used to eliminate undesirable characteristics like Insertion, Update, and Deletion
Anomalies.
First normal form Does not eliminate redundancy. but rather it's that's it elements
repeating groups.Instead of multiple columns of the same kind of data in a record you
would remove the repeated information into separate relationships and represent them
as rows. this is what consists 1NF
The second normal form is based on the concept of full functional dependency., the 2NF
normal form applies to relation with composite keys, that is relation with a primary key
composed of two or more attributes.A relation with a single attribute primary key is
automatically in at least 2NF.
A relation that Is not in 2NF May suffer from the update anomalies. To be in second form
a relation must be first normal form and relation must not contain any partial
dependency that is no non prime attribute is dependent on any proper subset of any
candidate key of the table.The normalizationnormalizationof 1NF RELATIONS 2NF Inwald
the removal or partial dependencies. If a partial dependency exists we remove the
partially dependent attribute from the relation by placing consider the example given
below.

In the given table, non-prime attribute TEACHER_AGE is dependent on TEACHER_ID which


is a proper
Subset of a candidate key.
2
Explain 1NF
Normalization is the process of organizing the data in the database.
Normalization is used to minimize the redundancy from a relation or set of relations. It is
also Used to eliminate undesirable characteristics like Insertion, Update, and Deletion
Anomalies.
→There are only single value attribute
→Attribute domain does not change
→ there is unique name for every attribute as well as column
→The order in which data is stored.
normalizatio the larger table into smaller and links them using relationships.
The normal form is used to reduce redundancy from the database table.

A relation is in 1NF if it contains atomic values. It states that an attribute of a table cannot
hold multiple
values. It must hold only single-values attributes. First normal form disallows the multi-
valued attributes,
composite attributes, and their combinations.

Consider a relation student (rollno, name, branch, address, phone).


3
Explain Important terms of relational ddatabases ?
Relations – Most of us know what a table is from using spreadsheet software. It is a grid
made up Of rows and columns. Well in relational databases we often refer to these as
“relations”. Tuples – A row in a table is known as a record, or a tuple. A tuple holds all the
data on a single Item. For example, if we have a table to store book details for a shop,
then each tuple is an Individual book the shop sells, and it will store all the data on that
individual book such as the ISBN, Book title and price.Attributes – An individual piece of
data in a record is known as a field, or attribute. In the previous Example we said that
each record for a book will store the ISBN, book title and price. Well these Three things
are all examples of attributes. Attributes appear as columns in a database table.

Domains – All the possible allowable values for an attribute. This is slightly different to
the data type of the attribute. For example, a field may have an integer number data
type, which defines that it can only allow whole numbers to be entered. However, there
may be additional rules applied,such as that the number must be between 1 & 10. The
domain would therefore be this range of whole numbers. Cardinality – How unique an
attribute is in terms of its data values. Some attributes will have a wide range of different
data values entered. For example, the primary key field will have a completely unique
value for every record. Where there is a large percentage of unique values, this is known
as “High Cardinality”. Where there are a lot of repeated values across the entities tuples,
this is known as having “Low Cardinality
4
Explain in detail types of anomaly?

Ans.
Normalization is the process of splitting relations into well-structured relations that allow
users To insert, delete, and update tuples without introducing database inconsistencies.
Without Normalization, many problems can occur when trying to load an integrated
conceptual model into the DBMS. These problems arise from relations that are generated
directly from user views are called Anomalies. There are three types of anomalies: update,
deletion, and insertion anomalies.
1)Update Anomaly-An update anomaly is a data inconsistency that results from data
redundancy and a Partial update. For example, each employee in a company has a
department associated with them as Well as the student group they participate in

2- Insertion Anomaly: Let’s say we have a table that has 4 columns. Student ID, Student
Name, Student Address and Student Grades. Now when a new student enroll in school,
Even though first three attributes can be filled but 4th attribute will have NULL value
Because he doesn’t have any marks yet.

3- Deletion Anomaly: This anomaly indicates unnecessary deletion of important


Information from the table. Let’s say we have student’s information and courses they have
Taken as follows (student ID,Student Name, Course, address). If any student leaves the
School then the entry related to that student will be deleted.
However, that deletion will Also delete the course information even though course
depends upon the school and not
The student.
5

What is Attribute with their types?


Attributes are the properties which define the entity type. For example, Roll No, Name,
DOB, Age, Address, Mobile No are the attributes which defines entity type Student. In ER

diagram, attribute is represented by an oval.


1. Key Attribute –
The attribute which uniquely identifies each entity in the entity set is called key attribute.
For example, Roll No will be unique for each student. In ER diagram, key attribute is
represented by an oval with underlying lines.

2. Composite Attribute – An attribute composed of many other attribute is called as


composite attribute. For example, Address attribute of student Entity type consists of
Street, City, State, and Country. In ER diagram, composite attribute is represented by an
oval comprising of ovals.

3. Multivalued Attribute – An attribute consisting more than one value for a given entity.
For example, Phone_No (can be more than one for a given student). In ER diagram,
multivalued attribute is Represented by double oval.

4. Derived Attribute –
An attribute which can be derived from other attributes of the entity type is known as
derived attribute. e.g.; Age (can be derived from DOB). In ER diagram, derived attribute
is represented by dashed oval.
6
Explain Extended E-R features?
Take an example – a person (name, street, city) be an entity set which is further classified

Among “customer” and “employee”.


Each of these person type is describe by a set of attributes that include all the attribute
Of entity set “person” plus possible additional attribute like “customer id” of “customer”
Entity. “employee id”, “salary” of “employee” entity.

1)Specialization –
The process of designating to sub grouping within an entity set is Called specialization. In
above figure, the “person” is distinguish in to whether they are“employee” or
“customer”.
Formally in above figure specialization is depicted by a triangle component labelled (is

2)Generalization –
generalization is relationship that exist between higher level entity set And one or more
lower level entity sets. Generalization synthesizes these entity sets into Single entity set

3)Higher level and lower level entity sets –


This property is created by specialization And generalization. The attributes of higher
level entity sets are inherited by lower level Entity sets. For example: In above figure
“customers” and “employee” inherits the attributes of “person”.
4)Attribute inheritance-
When given entity set is involved as a lower entity set in only One “ISA” (is a)
relationship, it is referred as a single attribute inheritance. If lower entity Set is involved
in more than one ISA (is a) relationship, it is referred as a multi attribute Inheritance.
5)Aggregation- there is a one limitation with E-R model that it cannot express
Relationships among relationships. So aggregation is an abstraction through which
Relationship is treated
7
BCNF Normal Form
Boyce Codd normal form (BCNF)
BCNF is the advance version of 3NF. It is stricter than 3NF.
A table is in BCNF if every functional dependency X → Y, X is the super key of the
table.For BCNF, the table should be in 3NF, and for every FD, LHS is super key.

Example: Let’s assume there is a company where employees work in more than one
department.

In the above table Functional dependencies are as follows:

EMP_ID → EMP_COUNTRY

EMP_DEPT → {DEPT_TYPE, EMP_DEPT_NO}

Candidate key: {EMP-ID, EMP-DEPT}

The table is not in BCNF because neither EMP_DEPT nor EMP_ID alone are keys.

To convert the given table into BCNF, we decompose it into three tables:
Functional dependencies:

EMP_ID → EMP_COUNTRY

EMP_DEPT → {DEPT_TYPE, EMP_DEPT_NO}

Candidate keys:
For the first table: EMP_ID
For the first table: EMP_DEPT
For the first table: {EMP_ID, EMP_DEPT}
Now, this is in BCNF because left side part of both the functional dependencies is a key.
8

Explain Structure of DBMS?


Ans. Structure of DBMS
Database Management System (DBMS) is a software that allows access to data stored in a
database and
Architecture of DBMS
1.Query Processor:
It interprets the requests (queries) received from end user via an Application program
into instructions. It also executes the userRequest which is received from the DML
compiler.Query Processor contains the following components –
• DML Compiler –It processes the DML statements into low level instruction (machine
language), so that they can be executed.
• DDL Interpreter –It processes the DDL statements into a set of table containing meta
data (data about data).
•Embedded DML Pre-compiler - It processes DML statements embedded in an application
program into procedural calls.
• Query Optimizer –It executes the instruction generated by DML Compiler.
2. Storage Manager: Storage Manager is a program that provides an interface
between the data stored in the database and the queries received. It is also known
as Database Control System. It maintains the consistency and integrity of the
database by applying the constraints and executes the DCL statements. It is
responsible for updating, storing, deleting, and retrieving data in the database.It
contains the following components –
- Authorization Manager –It ensures role-based access ccontro.
- Integrity Manager –it checks the integrity constraints when the database modified.
- Transaction Manager –It controls concurrent access by performing the operations
in a scheduled way that it receives the transaction.
- File Manager –It manages the file space and the data structure used to represent
information in the database.
- Buffer Manager –It is responsible for cache memory and the transfer of data
between the secondary storage and main memory.
3. Disk Storage: It contains the following components –Data Files – It stores the
data.Data Dictionary –It contains the information about the structure of any
database object. It is the repository of information that governs the metadata.
Indices –It provides faster retrieval of data item.
9
10
Explain normalisation and it’s type
Normalization is the process of organizing the data in the database. Normalization is used
to minimize the redundancy from a relation or set of relations. It is also Used to eliminate
undesirable characteristics like Insertion, Update, and Deletion Anomalies. Normalization
divides the larger table into smaller and links them using relationships.The normal form is
used to reduce redundancy from the database table.
1NF: The first normal form signifies that each cell of the table must only have single value.
Therefore, each intersection of rows and columns must hold atomic values. For example:
If we have a column name phone_number than each row for that column must save only
Single phone number.

2NF: We saw candidate key above and here is where it plays a role. 2NF rule signifies that
No non-prime attributes in the table are dependent on any of the candidate key. In
simple Words, If the table is representative of two different entities then it should be
broken down Into their own entities. For example: If we have a table (Student ID, Student
Name, Course Number, Course Name, Teacher ID, Teacher Name) this is representing
information about Each student enrolled in each course which is taught by each teacher
in school. Since it is A representative of three different entities it must be normalized into
2NF form.

3NF: This rule signifies that tables must be in 2NF form and each table should only contain
Columns that are non-transitively depended on primary key of their own table. In simple
Words, if we have a table (Transaction ID, price, quantity, total_sales) here the total sales
Is the product of price and quantity (price*quantity). Hence sales is transitively depended
In Transaction ID which is a primary key here. So each attribute must directly depend
upon The primary key.
BCNF Normal Form
Boyce Codd normal form (BCNF)
BCNF is the advance version of 3NF. It is stricter than 3NF.
11
What is Functional Dependency? It’s types
Functional Dependency (FD) is a constraint that determines the relation of one attribute
to another Attribute in a Database Management System (DBMS). Functional Dependency
helps to maintain the Quality of data in the database. It plays a vital role to find the
difference between good and bad Database design.A functional dependency is denoted
by an arrow “→”. The functional dependency of X on Y is Represented by X → Y.
There are mainly four types of Functional Dependency in DBMS. Following are the types
of Functional Dependencies in DBMS:
1.Multivalued Dependency in DBMS → Multivalued dependency occurs in the situation
where there are multiple independent multivalued attributes in a single.
Car_model. Maf_ year. Color
H001. 2017. Green
H001. 2018. Red
2.Trivial Functional Dependency in DBMS
The Trivial dependency is a set of attributes which are called a trivial if the set of
attributes are included In that attribute.So, X -> Y is a trivial functional dependency if Y is
a subset of X. Let’s understand with a Trivial Functional Dependency Example.
Emp_id. Emp_name
AS555. Harry
AS811 George
AS999 Kevin
i

3.Non Trivial Functional Dependency in DBMS→Functional dependency which also known


as a nontrivial dependency occurs when A->B holds true Where B is not a subset of A.
Company CEO. Age.
Microsoft Satya Nadella 51
Google Sundar Pichai 46

4.Transitive Dependency in DBMS→A Transitive Dependency is a type of functional


dependency which happens when t is indirectly formed By two functional dependencies.
Let’s understand with the following Transitive Dependency Example.

Company CEO. Age.


Microsoft Satya Nadella 51
Google Sundar Pichai 46
12
Explain 3NF
A relation is in third normal form, if there is no transitive dependency
for non-prime attributes as well as it is in second normal form.A
relation is in 3NF if at least one of the following condition holds in
every non-trivial function dependency X –> Y:X is a super key.Y is a
prime attribute (each element of Y is part of some candidate key).The
normalization of 2NF relations to 3NF involves the removal of
transitive dependencies. If a transitive dependency exists, we remove
the transitively dependent attribute(s) from the relation by placing
the attribute(s) in a new relation along with a copy of the
determinant.Consider the examples given below.
Example-

FD set:
{STUD_NO -> STUD_NAME, STUD_NO -> STUD_STATE, STUD_STATE ->
STUD_COUNTRY, STUD_NO -> STUD_AGE}
Candidate Key:
{STUD_NO}
STUD_NO -> STUD_STATE and STUD_STATE -> STUD_COUNTRY are
true. So STUD_COUNTRY is transitively dependent on STUD_NO. It
violates the third normal form. To convert it in third normal form, we
will decompose the relation STUDENT (STUD_NO, STUD_NAME,
STUD_PHONE, STUD_STATE, STUD_COUNTRY_STUD_AGE)
13
Explain user of DBMS ?
Database users are categorized based up on their interaction with the data base.
These are seven types of data base users in DBMS.
1.Database Administrator (DBA) :
Database Administrator (DBA) is a person/team who defines the schema and also
controls the 3 levels of database.The DBA will then create a new account id and password
for the user if he/she need to access the data base.
DBA also monitors the recovery and back up and provide technicalsupport.
The DBA has a DBA account in the DBMS which called a system or superuser account.
DBA repairs damage caused due to hardware and/or software failures.
2.Naive / Parametric End Users :
Parametric End Users are the unsophisticated who don’t have any DBMS knowledge but
they frequently use the data base applications in their daily life to get the desired results.
3. System Analyst:
System Analyst is a user who analyzes the requirements of parametric end users. They
check whether all the requirements of end users are satisfied.
4. Sophisticated Users :
Sophisticated users can be engineers, scientists, business analyst, who are familiarWith
the database. They can develop their own database applications according to
their requirement. They don’t write the program code but they interact the data base
by writing SQL queries directly through the query processor.
5. Data Base Designers :Data Base Designers are the users who design the structure of
data base which includes tables, indexes, views, constraints, triggers, stored procedures.
He/she controls what data must be stored and how the data items to be related.
6. Application Program :Application Program are the back end programmers who writes
the code for the application programs. Programming languages such as Visual Basic,
Developer, C, FORTRAN, COBOL etc.
7.Casual Users / Temporary Users :Casual Users are the users who occasionally
use/access the data base but each time when they access the data base they require the
new information, for example, Middle or higher level manager.
14

What is Indexing? And types


Indexing is a data structure technique which allows you to quickly retrieve records
from a database file. An Index is a small table having only two columns. The first
column comprises a copy of the primary or candidate key of a table. Its second
column contains a set of pointers for holding the address of the disk block where
that specific key value stored.
Indexing in Database is defined based on its indexing attributes. Two main
types of indexing methods are:
1.Primary Indexing
2.Secondary Indexing
Primary Index
Primary Index is an ordered file which is fixed length size with two fields. The
first field is the same a primary key and second, filed is pointed to that specific
data block. In the primary Index, there is always one to one relationship between
the entries in the index table.
The primary Indexing in DBMS is also further divided into two types.
Dense Index
• Sparse Index
• Dense Index
Dense index
In a dense index, a record is created for every search key valued in the database. This
helps you to search faster but needs more space to store index records. In this Indexing,
method records contain search key value and points to the real record on the disk.
• Sparse Index
It is an index record that appears for only some of the values in the file. Sparse Index
helps you to resolve the issues of dense Indexing in DBMS.
2. Secondary Index
The secondary Index in DBMS can be generated by a field which has a unique value
for each record, and it should be a candidate key. It is also known as a non-clustering
index.
Clustering Index
In a clustered index, records themselves are stored in the Index and not pointers.
Sometimes the Index is created on non-primary key columns which might not be
unique for each record.
Multilevel Index: Multilevel Indexing in Database is created when a primary index
does not fit in memory.
15

Explain data model in DBMS


Data Model gives us an idea that how the final system will look like after its complete
implementation. It defines the data elements and the relationships between the data
elements. Data Models are used to show how data is stored, connected, accessed and
updated in the database management system. Here, we use a set of symbols and text to
represent the information so that members of the organization can communicate and
understand it. Though there are many data models being used nowadays but the
Relational model is the most widely used model. Apart from the Relational model, there
are many other types of data models about which we will study in details in this blog.
Some
of the Data Models in DBMS are:
1. Hierarchical Model
2. Network Model
3. Entity-Relationship Model
4. Relational Model
5. Object-Oriented Data Model
6. Object-Relational Data Model
7. Flat Data Model
8. Semi-Structured Data Model
9. Associative Data Model
10. Context Data Model
16

Components of ER model

As shown in the above diagram, an ER diagram has three main components:


Entity Attribute Relationship
1. Entity An entity is an object or component of data. An entity is represented as
rectangle in an ER diagram.For example:

Weak Entity:
An entity that cannot be uniquely identified by its own attributes and relies on the
relationship With other entity is called weak entity
2.Attribute
1. Key attribute
2.Composite attribute
3. Multivalued attribute
4. Derived attribute
1-A key attribute can uniquely identify an entity from an entity set. For example, student
roll Number can uniquely identify a student from a set of students.
2- An attribute that is a combination of other attributes is known as composite attribute.
For example, In student entity, the student address is a composite attribute as an address
is composed of other attributes such as pin code, state, country.
3-An attribute that can hold multiple values is known as multivalued attribute. It is
represented with Double ovals in an ER Diagram.
4- A derived attribute is one whose value is dynamic and derived from another attribute.
It is represented by dashed oval in an ER Diagram.
3. Relationship
A relationship is represented by diamond shape in ER diagram, it shows the relationship
among entities. There are four types of relationships:
1. One to One
2. One to Many
3. Many to One
4. Many to Many
17

Explain ER Diagram
An ER diagram shows the relationship among entity sets. An entity
set is a group of similar entities and these entities can have
attributes. In terms of DBMS, an entity is a table or attribute of a
table in database, so by showing relationship among tables and their
attributes, ER diagram shows the complete logical structure of a
database. Lets have a look at a simple ER diagram to understand
this concept.
A simple ER Diagram:
In the following diagram we have two entities Student and College
and their relationship. The relationship between Student and College
is many to one as a college can have many students however a
student cannot study in multiple colleges at the same time. Student

entity has attributes such as Stu_Id, Stu_Name & Stu_Addr and College
entity has attributes such as

Rectangle: Represents Entity sets.


Ellipses: Attributes
Diamonds: Relationship Set
Lines: They link attributes to Entity Sets and Entity sets to
Relationship Set
Double Ellipses: Multivalued Attributes
Dashed Ellipses: Derived Attributes
Double Rectangles: Weak Entity Sets
Double Lines: Total participation of an entity in a relationship set
18

Explain Cardinality
Databases have a lot of jargon, and cardinality is one of those words that experienced
people Tend to forget that they didn’t know once upon a time. But if
you don’t know it—and it takes a While to really get comfortable
with cardinality—it’s super confusing when the DBA just drops it
Into the middle of a sentence without slowing down! Fear not: I’ve
got you, as they say.
Cardinality means two things in databases. For our purposes, one
matters a lot more than the Other. Let’s do the simple one first, and
then dig into the one that matters for query performance. The
definition of cardinality that matters a lot for query performance is
data cardinality. This is
All about how many distinct values are in a column.The first meaning
of cardinality is when you’re Designing the database—what’s called
data modeling. In this sense, cardinality means whether a
Relationship is one-to-one, many-to-one, or many-to-many. So you’re
really talking about The relationship cardinality. Cardinality’s official,
non-database dictionary definition is Mathematical.
19

Explain Aggregation
Aggregation –
An ER diagram is not capable of representing relationship between an
entity and a relationship which may be required in some scenarios. In
those cases, a relationship with its corresponding entities is
aggregated into a higher level entity. Aggregation is an abstraction
through which we can represent relationships as higher level entity
sets.
For Example, Employee working for a project may require some
machinery. So, REQUIRE relationship is needed between relationship
WORKS_FOR and entity MACHINERY. Using aggregation, WORKS_FOR
relationship with its entities EMPLOYEE and PROJECT is aggregated
into single entity and relationship REQUIRE is created between
aggregated entity and MACHINERY.
20

You might also like