3. Normalization: The biggest problem needed to be solved in database is data
redundancy. Normalization is a process which can remove or reduce
redundancy of a database.
Why data redundancy is the problem?
Because it causes:
1. Insert Anomaly
2. Update Anomaly
3. Delete Anomaly
Steps of Normalization
First Normal Form (1NF)
Second Normal Form (2NF)
Third Normal Form (3NF)
4. Table Student:
Student_ID Name Subject PostCode City
10617 Rinku DBMS,AOL 1212 Lalbagh
10571 Susmita DBMS,NETWORKI
NG
1204 Sahabagh
10741 Shakir DBMS,C 1309 Mirpur01
10546 Rod DBMS 1407 Mirpur14
5. 1st Normal Form:
1.Each attribute name must be unique.
2. Each attribute value must be single.
3. Each row must be unique.
4. There is no repeating groups.
Student_ID Name Subject PostCode City
10617 Rinku DBMS 1212 Lalbagh
10617 Rinku AOL 1212 Lalbagh
10571 Susmita DBMS 1204 Shahabagh
10571 Susmita NETWORKING 1204 Shahabagh
10741 Shakir DBMS 1309 Mirpur01
10741 Shakir C 1309 Mirpur01
10546 Rod DBMS 1407 Mirpur14
6. 2ND Normal Form:
1. A table is already in 1NF.
2. All nonkey attributes are fully dependent on the primary key. All partial dependencies are
removed to place in another table.
Table: Student_Info Table:Student_Sub
Student_ID Name PostCode City
10617 Rinku 1212 Lalbagh
10571 Susmita 1204 Shahabagh
10741 Shakir 1309 Mirpur01
10546 Rod 1407 Mirpur14
Student_ID Subject
10617 DBMS
10617 AOL
10571 DBMS
10571 NETWORKIN
G
10741 DBMS
10741 C
10546 DBMS
7. 3rd Normal Form:
1. A table is already in 2NF.
2.Nonprimary key attributes do not depend on other nonprimary key attributes (i.e. no transitive
dependencies) All transitive dependencies are removed to place in another table.
Table: Student_Info Table:Student_city
Table:
Student_Sub
Student_Id Name PostCode
10617 Rinku 1212
10571 Susmita 1204
10741 Shakir 1309
10546 Rod 1407
PostCode City
1212 Lalbagh
1204 Sahabagh
1309 Mirpur01
1407 Mirpur14
Student_ID Subject
10617 DBMS
10617 AOL
10571 DBMS
10571 NETWORK
ING
10741 DBMS
10741 C
10546 DBMS
8.
9. Functional Dependency: Functional dependency is a relationship that
exists when one attribute uniquely determines another attributes. If 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.
For Example :- Suppose we have a student table with attributes:
Stu_ID, Stu_Name, Stu_Age. Here Stu_ID attribute uniquely identifies
the Stu_Name attribute of student table because ID we can tell the
student name associated with it.
Full Functional Depenedency:A Functional Dependency X Y is a full
functional dependency if removal of any attributes A from X means that
the dependency does not hold any more.
11. Partial Functional Dependency: Partial Dependency occurs when a non-prime attribute
is functionally dependent on part of a candidate key.
The 2nd Normal Form (2NF) eliminates the Partial Dependency.
Here Roll_No , Project_No are the primary attributes.
Roll_No Student_Name
Project_No Project_Name
Roll_No Project_No Student_Name Project_Name
01 20 Rinku SRT
02 34 Susmita BGY
03 21 Shakir XYZ
12. Transitive Functional Dependency:A functional dependency is said to be
transitive if it is indirectly formed by two functional dependencies.
X->Z is a transitive dependency if the following three functional dependencies hold true:
• X->Y
• Y does not -> X
• Y->Z
A transitive dependency can only occur in a relation of three of more attributes. This
dependency helps us normalizing the database in 3NF (3rd Normal Form).
Example:
Book Author Author_Age
Sherlcok Holmes Conan Doyle 66
Harry Potter J.K.Rowling 49
Dying Of the Light George R.R Martin 68
13. {Book}->{Author} (if we know the book, we knows the author name)
{Author} does not->{Book}
{Author} ->{Author_age}
Therefore as per the rule of transitive dependency.
{Book}->{Author_age} should hold, that makes sense because if we
know the book name we can know the author’s age.
14.
15. KEY:A key part of a relational database and a vital part of the structure of a table.
They ensure each record within a table can be uniquely identified by one or a
combination of fields within the table. They help enforce integrity and help identify
the relationship between tables.
Super key: A super key is a set of one or more attributes (columns), which can
uniquely identify a row in a table.
Example:
The Car relation schema:
CAR(State, Reg, SerialNo, Make, Model, Year)
Here Super key is {SrialNo, Make}
A candidate key is a super key but vice versa is not true.
16. Primary Key: A primary key is used as a unique identifier to quickly parse
data within the database and find the relation between different tables. A
relational database cannot have more than one primary key.
Example:
17. Candidate key: A candidate key is a column, or set of columns, in a table that
can uniquely identify any database record without referring to any other data.
Each table may have one or more candidate keys, but one candidate key is
unique, and it is called the primary key.
Example:
18. Foreign Key: A foreign key is a column or group of columns in a relational
database table that provides a link between data in two tables. It acts as a
cross-reference between tables because it references the primary key of another
table, thereby establishing a link between them.
Example:
19.
20. DDL:
DDL stands for Data Definition Language.
DDL statements are used to build and modify the structure of tables and other objects
in the database
DDL is a sub-language of SQL used to create and manipulate objects in a database
Advantages of DDL :
Shared data
Data independence
Improved integrity
Multiple user
Improved security
Efficient data access
21. DML:
DML stands for Data Manipulation Language.
A DML is a family of syntax elements similar to a computer programming language
used for
selecting,
inserting,
deleting and
updating data in a database.
Advantages of DML:
The DML statements can modify the data stored in a database.
User can specify what data is needed.
DML tends to have many different flavors and capabilities between database vendors.
It provides efficient human interaction with the system.
22. Disadvantages of DML:
DML cannot be used to change the database structure.
Tables or columns cannot be created or deleted using DML.
View the data without storing the data into the object.
Restrict the view of a table i.e. Can hide some of columns in the tables.
23.
24. Generalization: In generalization, a number of entities are brought together
into one generalized entity based on their similar characteristics.
Example:
25. Specialization: A group of entities is divided into sub-groups based on their
characteristics. Specialization is the just opposite of generalization.
Example: