DBMS Practicle

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 17

Normalization:

Normalization is a process of organizing the data in database to avoid data redundancy, insertion
anomaly, update anomaly & deletion anomaly.

Anomalies in DBMS
Data modification anomalies can be categorized into three types:

 Insertion Anomaly: Insertion Anomaly refers to when one cannot insert a new tuple into
a relationship due to lack of data.
 Deletion Anomaly: The delete anomaly refers to the situation where the deletion of data
results in the unintended loss of some other important data.
 Up-dation Anomaly: The update anomaly is when an update of a single data value
requires multiple rows of data to be updated.

Types of Normal Forms:


Normal Form Description

1NF A relation is in 1NF if it contains an atomic value.

2NF A relation will be in 2NF if it is in 1NF and all


non-key attributes are fully functional dependent
on the primary key.

3NF A relation will be in 3NF if it is in 2NF and no


transition dependency exists.

BCNF A stronger definition of 3NF is known as Boyce


Codd's normal form.

4NF A relation will be in 4NF if it is in Boyce Codd's


normal form and has no multi-valued dependency.
5NF A relation is in 5NF. If it is in 4NF and does not
contain any join dependency, joining should be
lossless.

Or with example detail:

First normal form (1NF)


A relation is said to be in 1NF (first normal form), if it doesn’t contain any multi-valued
attribute. In other words, you can say that a relation is in 1NF if each attribute contains only
atomic(single) value only.

Second normal form (2NF)


A table is said to be in 2NF if both the following conditions hold:

 Table is in 1NF (First normal form)


 No non-prime attribute is dependent on the proper subset of any candidate key of table.

An attribute that is not part of any candidate key is known as non-prime attribute.

Third Normal form (3NF)

A table is in 3NF if it is in 2NF and for each functional dependency X-> Y at least one of
the following conditions hold:

 X is a super key of table


 Y is a prime attribute of table

An attribute that is a part of one of the candidate keys is known as prime attribute.

An attribute that is not part of any candidate key is known as non-prime attribute.
Boyce Codd normal form (BCNF)
It is an advance version of 3NF that’s why it is also referred as 3.5NF. BCNF is stricter than 3NF.
A table complies with BCNF if it is in 3NF and for every functional dependency X->Y, X
should be the super key of the table.

Fourth normal form (4NF)


 A relation will be in 4NF if it is in Boyce Codd normal form and has no multi-valued
dependency.
 For a dependency A → B, if for a single value of A, multiple values of B exist, then the
relation will be a multi-valued dependency.

Fifth normal form (5NF)


 A relation is in 5NF if it is in 4NF and not contains any join dependency and joining
should be lossless.
 5NF is satisfied when all the tables are broken into as many tables as possible in order to
avoid redundancy.
 5NF is also known as Project-join normal form (PJ/NF).
Join
Join is a combination of a Cartesian product followed by a selection process. A Join operation
pairs two tuples from different relations, if and only if a given join condition is satisfied.

Types of Joins:

Inner Join
Inner Join is a join that can be used to return all the values that have matching values in both the
tables.

Syntax:

SELECT StudentCourse.COURSE_ID, Student.NAME, Student.AGE FROM Student


INNER JOIN StudentCourse
ON Student.ROLL_NO = StudentCourse.ROLL_NO;
The inner join can be further divided into the following types:
1. Theta Join
2. Equi Join
3. Natural Join

Theta Join
Theta join combines tuples from different relations provided they satisfy the theta condition. The
join condition is denoted by the symbol θ.

Notation
R1 ⋈θ R2

Equi Join
Equi Join is an inner join that uses the equivalence condition for fetching the values of two tables.
Select employee.empId, employee.empName, department.deptName

from employee Inner Join department on employee.deptId = department.deptId;

Natural Join (⋈)


Natural Join is an inner join that returns the values of the two tables on the basis of a common
attribute that has the same name and domain.

The MySQL query for natural join can be as follows:


Select * from employee Natural Join department;

Outer Join
Outer Join is a join that can be used to return the records in both the tables whether it has
matching records in both the tables or not.

The outer join can be further divided into three types:

1. Left-Outer Join

2. Right-Outer Join

3. Full-Outer Join

LEFT JOIN (R S)

This join returns all the rows of the table on the left side of the join and matches rows for the
table on the right side of the join. For the rows for which there is no matching row on the right
side, the result-set will contain null. LEFT JOIN is also known as LEFT OUTER JOIN.

Syntax:
Select employee.empId, employee.empName, department.deptName

from employee Left Outer Join department on employee.deptId = department.deptId;

Right Outer Join: ( R S)


All the tuples from the Right relation, S, are included in the resulting relation. If there are tuples
in S without any matching tuple in R, then the R-attributes of resulting relation are made NULL.

Syntax:

Select employee.empId, employee.empName, department.deptName from employee Right Outer


Join department on employee.deptId = department.deptId;
Full Outer Join: ( R S)
All the tuples from both participating relations are included in the resulting relation. If there are
no matching tuples for both relations, their respective unmatched attributes are made NULL.

Syntax:

Select * from employee Full Join department;


Union:
The Union is a binary set operator in DBMS. The UNION command combines the result set of
two or more SELECT statements (only distinct values). Thus, It combines two result sets into
one.

The following SQL statement returns the cities (only distinct values) from both the "Customers"
and the "Suppliers" table:

Example
SELECT City FROM Customers
UNION
SELECT City FROM Suppliers
ORDER BY City;

Conditions:
Both SELECT statements should have an equal number of fields in the same order.

The data types of these fields should either be the same or compatible with each other.
Union All:
Union All operation is also similar to the union operation. The only difference is that it
allows duplicate values in the result set.

Syntax:
SELECT color_name FROM colors_a UNION ALL SELECT color_name FROM colors_b;
Computer networking:
Open system:
A system which is connected to the network and is ready for communication.

Closed system:
A system which is not connected to the network and can’t be communicated with.

Computer Network:
An interconnection of multiple devices, also known as hosts, that are connected using multiple
paths for the purpose of sending/receiving data or media.

Computer Network Components

Switches
Switches work as a controller which connects computers, printers, and other hardware devices to
a network in a campus or a building.

Routers
Routers help you to connect with multiple networks. It enables you to share a single internet
connection with multiple devices and saves money.

Servers:
Servers are computers that hold shared programs, files, and the network operating system.
Clients:
Clients are computer devices which access and uses the network as well as shares network
resources.

Transmission Media:
Transmission media is a carrier used to interconnect computers in a network, such as coaxial
cable, twisted-pair wire, and optical fiber cable. It is also known as links, channels, or lines.

Shared Data:
Shared data are data which is shared between the clients such as data files, printer access
programs, and email.

Network Interface Card:


Network Interface card sends, receives data, and controls data flow between the computer and the
network.

Hub:
Hub is a device that splits network connection into multiple computers.

Protocol:
A protocol is the set of defined rules that allows two entities to communicate across the network.

Network Topology:
The arrangement of a network that comprises nodes and connecting lines via sender and receiver
is referred to as network topology. Common examples include: Bus, Star, Mesh, Ring, and Daisy
chain.

Mesh Topology:
In a mesh topology, every device is connected to another device via a particular channel.
Star Topology:
In star topology, all the devices are connected to a single hub through a cable.

Bus Topology:
Bus topology is a network type in which every computer and network device is connected to a
single cable. It transmits the data from one end to another in a single direction.
Ring Topology:
In this topology, it forms a ring connecting devices with exactly two neighboring devices.

Tree Topology :
This topology is the variation of the Star topology. This topology has a hierarchical flow of data.
In Tree Topology, SAC (Standard Automatic Configuration ) protocols like DHCP and SAC are
used.

Hybrid Topology :
It is used when the nodes are free to take any form. It means these can be individuals such as
Ring or Star topology or can be a combination of various types of topologies.
OSI Model
The Open Systems Interconnection (OSI) model describes seven layers that computer systems
use to communicate over a network. It was the first standard model for network communications,
adopted by all major computer and telecommunication companies in the early 1980s

You might also like