You are on page 1of 4

DBMS :-

-----------------------------------------------------------------------------------
--------------------------------------
-----------------------------------------------------------------------------------
--------------------------------------
NORMAL FORMS
Normalization is a database design technique that reduces data redundancy and
eliminates undesirable characteristics
like Insertion, Update and Deletion Anomalies. Normalization rules divides larger
tables into smaller tables and links
them using relationships. The purpose of Normalisation in SQL is to eliminate
redundant (repetitive) data and ensure
data is stored logically.

● First Normal Form (1NF) - Each table cell should contain a single value.
Each record needs to be unique.

● Second Normal Form (2NF) - A given relation is called in Second Normal Form (2NF)
if
and only if
1)Relation already exists in 1NF.
2)No partial dependency exists in the relation=>

-----------------------------------------------------------------------------------
--------------------------------------
PARTIALLY DEPENDENT With example : Partial Dependency occurs when a non-prime
attribute is functionally
dependent on part of a candidate key.

link : https://www.tutorialspoint.com/Partial-Dependency-in-DBMS#:~:text=What%20is
%20Partial%20Dependency%3F,2NF)%20eliminates%20the%20Partial%20Dependency.

EG:-
The StudentName can be determined by StudentID, which makes the relation Partial
Dependent.
The ProjectName can be determined by ProjectNo, which makes the relation Partial
Dependent.
Therefore, the <StudentProject> relation violates the 2NF in Normalization and is
considered a bad database design.
so we splited table in 2
-----------------------------------------------------------------------------------
--------------------------------------
Partial Dependency Eg2:-
Partial Dependency is one kind of functional dependency that occur when key must be
candidate key and non prime
attribute are depends on the subset/part of candidates key.

candidates key => more than one primary key.

Try to understand partial dependency relate through example :

Seller(Id, Product, Price)

Candidate Key : Id, Product


Non prime attribute : Price

Price attribute only depends on only Product attribute which is a subset of


candidate key,
Not the whole candidate key(Id, Product) key . It is called partial dependency.

So we can say that Product->Price is partial dependency.

-----------------------------------------------------------------------------------
--------------------------------------
● Third Normal Form (3NF) - A given relation is called in Third Normal Form (3NF)
if and
only if
o be in 2NF.
o No transitive dependency exists for non-prime attributes.
//A → B is called a transitive dependency if and only if- A is not a super key and
B
is a non-prime attribute.
-----------------------------------------------------------------------------------
--------------------------------------
● Boyce-Codd Normal Form - A given relation is called in BCNF if and only if
o Relation already exists in 3NF.
o For each non-trivial functional dependency ‘A → B’, A is a super key of the
relation
-----------------------------------------------------------------------------------
--------------------------------------
ACID properties
A Atomicity : this property ensures that trasaction happens fully or doesnt occcur
at all, no partial occuracncy as such
C consistency : it ensures integrity to be maintained, or db remains consistent
before and after trascation
I isloation : this property ensures that trasaction occurs simultansouly without
causing inconsstency
D durability : this ensures that all changes after trascation are saved on disk
succesfully, if there is power faillure
we can retrive that data
-----------------------------------------------------------------------------------
--------------------------------------
• Relational Algebra is procedural query language, which takes Relation as input
and generate relation as output
There are few fundamental operations of relational algebra:
select
project
set difference
union
rename,etc.
-----------------------------------------------------------------------------------
--------------------------------------
• Joins:-The Join operation is one of the most useful activities in relational
algebra.
It is most commonly used way to combine information from two or more relations.
A Join is always performed on the basis of the same or related column.
Most complex queries of SQL involve JOIN command.
4 joins read from NB
-----------------------------------------------------------------------------------
--------------------------------------
• Indexing :
What is Indexing?
Indexing is a data structure technique which allows us 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.

An index –
#Takes a search key as input
#Efficiently returns a collection of matching records.

Advantages of Indexing:
It helps you to reduce the total number of I/O operations needed to retrieve that
data, so you don’t need to access a row
in the database from an index structure.
Offers Faster search and retrieval of data to users.
Indexing also helps you to reduce tablespace as you don’t need to link to a row in
a table, as there is no need to store
the ROWID in the Index. Thus you will able to reduce the tablespace.
You can’t sort data in the lead nodes as the value of the primary key classifies
it.

Disadvantages of Indexing
To perform the indexing database management system, you need a primary key on the
table with a unique value.
You can’t perform any other indexes in Database on the Indexed data.
You are not allowed to partition an index-organized table.
SQL Indexing Decrease performance in INSERT, DELETE, and UPDATE query.

Summary:
>Indexing is a small table which is consist of two columns.
>Two main types of indexing methods are 1)Primary Indexing 2) Secondary Indexing.
>Primary Index is an ordered file which is fixed length size with two fields.
>The primary Indexing is also further divided into two types 1)Dense Index 2)Sparse
Index.
>In a dense index, a record is created for every search key valued in the database.
>A sparse indexing method helps you to resolve the issues of dense Indexing.
>The secondary Index in DBMS is an indexing method whose search key specifies an
order different from the sequential order
of the file.
>Clustering index is defined as an order data file.
>Multilevel Indexing is created when a primary index does not fit in memory.
>The biggest benefit of Indexing is that it helps you to reduce the total number of
I/O operations needed to retrieve that
data.
>The biggest drawback to performing the indexing database management system, you
need a primary key on the table with a
unique value.
-----------------------------------------------------------------------------------
--------------------------------------
• What is Correlated Subquery in DBMS?
A Subquery is also known as a nested query i.e. a query written inside some query.
When a Subquery is executed for
each of the rows of the outer query then it is termed as a Correlated Subquery.

-----------------------------------------------------------------------------------
--------------------------------------
• sql vs mysql :

#SQL is a language which is used to operate your database whereas MySQL was one of
the first open-source database
available in the market
#SQL is used in the accessing, updating, and manipulation of data in a database
while MySQL is an RDBMS that allows
keeping the data in organized manner

#SQL is a Structured Query Language and MySQL is a RDBMS to store, retrieve, modify
and administrate a database.

#SQL is a query language while MYSQL is a database software

# sql : The language is fixed, and command remains the same.


Mysql : Get the frequent updates
-----------------------------------------------------------------------------------
--------------------------------------
• What is functional Dependency?
This is basically a constraint that is useful in describing the relationship among
the different attributes in a relation
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.

Eg of fd : Example: If there is some relation ‘R1’ which has 2 attributes as Y and


Z then the functional dependency
among these 2 attributes can be shown as Y->Z which states that Z is functionally
dependent on Y.

• Advantages of Functional Dependency


->Functional Dependency avoids data redundancy. Therefore same data do not repeat
at multiple locations in that database
It helps you to maintain the quality of data in the database-> basically
consistency
It helps you to defined meanings and constraints of databases
It helps you to identify bad designs
It helps you to find the facts regarding the database design

You might also like