SlideShare a Scribd company logo
1 of 25
Normalization


              BY,
         Karan R. Kotecha
Database Normalization
   Database normalization is the process of removing
    redundant data from your tables in to improve storage
    efficiency, data integrity, and scalability.
   In the relational model, methods exist for quantifying how
    efficient a database is. These classifications are called
    normal forms (or NF), and there are algorithms for
    converting a given database between them.
   Normalization generally involves splitting existing tables
    into multiple ones, which must be re-joined or linked
    each time a query is issued.
History

   Edgar F. Codd first proposed the process of
    normalization and what came to be known as
    the 1st normal form in his paper A Relational
    Model of Data for Large Shared Data Banks
    Codd stated:
    “There is, in fact, a very simple elimination
    procedure which we shall call normalization.
    Through decomposition nonsimple domains are
    replaced by „domains whose elements are
    atomic (nondecomposable) values.’”
Normal Form
   Edgar F. Codd originally established three
    normal forms: 1NF, 2NF and 3NF. There
    are now others that are generally
    accepted, but 3NF is widely considered to
    be sufficient for most applications. Most
    tables when reaching 3NF are also in
    BCNF (Boyce-Codd Normal Form).
Table 1

Title       Author1        Author   ISBN         Subject     Pages   Publisher
                           2
Database    Abraham        Henry F. 0072958863   MySQL,      1168    McGraw-Hill
System      Silberschatz   Korth                 Computers
Concepts


Operating   Abraham        Henry F. 0471694665   Computers   944     McGraw-Hill
System      Silberschatz   Korth
Concepts
Table 1 problems

   This table is not very efficient with storage.

   This design does not protect data integrity.

   Third, this table does not scale well.
First Normal Form
 In our Table 1, we have two violations of
  First Normal Form:
 First, we have more than one author field,
 Second, our subject field contains more
  than one piece of information. With more
  than one value in a single field, it would be
  very difficult to search for all books on a
  given subject.
First Normal Table

       Table 2

Title              Author           ISBN         Subject     Pages   Publisher

Database System    Abraham          0072958863   MySQL       1168    McGraw-Hill
Concepts           Silberschatz
Database System    Henry F. Korth   0072958863   Computers   1168    McGraw-Hill
Concepts

Operating System   Henry F. Korth   0471694665   Computers   944     McGraw-Hill
Concepts

Operating System   Abraham          0471694665   Computers   944     McGraw-Hill
Concepts           Silberschatz
 We now have two rows for a single book.
  Additionally, we would be violating the
  Second Normal Form…
 A better solution to our problem would be
  to separate the data into separate tables-
  an Author table and a Subject table to
  store our information, removing that
  information from the Book table:
Subject Table

Subject_ID       Subject

1                MySQL

2                Computers
                                            Author Table

                                        Author_ID       Last Name   First Name

                                        1               Silberschatz Abraham


                                        2               Korth       Henry
    Book Table

ISBN         Title              Pages       Publisher

0072958863   Database System    1168        McGraw-Hill
             Concepts

0471694665   Operating System   944         McGraw-Hill
             Concepts
 Each table has a primary key, used for
  joining tables together when querying the
  data. A primary key value must be unique
  with in the table (no two books can have
  the same ISBN number), and a primary
  key is also an index, which speeds up data
  retrieval based on the primary key.
 Now to define relationships between the
  tables
Relationships

 Book_Author Table
                           Book_Subject Table
ISBN           Author_ID

0072958863     1           ISBN         Subject_ID

0072958863     2           0072958863   1

0471694665     1           0072958863   2

0471694665     2           0471694665   2
Second Normal Form
   As the First Normal Form deals with redundancy
    of data across a horizontal row, Second Normal
    Form (or 2NF) deals with redundancy of data in
    vertical columns.
   As stated earlier, the normal forms are
    progressive, so to achieve Second Normal
    Form, the tables must already be in First Normal
    Form.
   The Book Table will be used for the 2NF
    example
2NF Table
             Publisher Table

             Publisher_ID   Publisher Name

             1              McGraw-Hill




  Book Table
ISBN             Title              Pages    Publisher_ID


0072958863       Database System    1168     1
                 Concepts

0471694665       Operating System   944      1
                 Concepts
2NF
   Here we have a one-to-many relationship
    between the book table and the publisher. A
    book has only one publisher, and a publisher will
    publish many books. When we have a one-to-
    many relationship, we place a foreign key in the
    Book Table, pointing to the primary key of the
    Publisher Table.
   The other requirement for Second Normal Form
    is that you cannot have any data in a table with a
    composite key that does not relate to all portions
    of the composite key.
Third Normal Form
 Third normal form (3NF) requires that
  there are no functional dependencies of
  non-key attributes on something other
  than a candidate key.
 A table is in 3NF if all of the non-primary
  key attributes are mutually independent
 There should not be transitive
  dependencies
Boyce-Codd Normal Form
   BCNF requires that the table is 3NF and
    only determinants are the candidate keys
Fourth Normal Form (4NF)

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.
5th Normal Form
The 5th Normal Form is a “projection-based normalization approach where
every nontrivial join dependency is implied by a candidate key”. In the previous
example, I showed how one table became two, reducing the risk of data
anomalies. 5th normal form could split a single table into three or more.
Let‟s say you have a table with store, supplier, and products. The table contains
a row for each store, which is repeated for each supplier the store uses, and
again for each product that the supplier provides to the particular store (A store
might not sell all the products that a supplier provides). All fields in this table are
valuable and necessary to represent the row and is in 4th Normal Form. In fact,
this is a common type of table that could represent a many-to-many-to-many
relationship among stores, products, and suppliers. But, notice that there is
repeating data:
When a store picks up a new supplier, a
new row is added to the store_to_supp
table, eliminating the redundancy of extra
rows for product. When a store sells a new
product, the supp_to_prod table will let you
know where to get it. A simple example, yes
— but it demonstrates 5th normal form.
Karan normalization in sql

More Related Content

What's hot

What's hot (20)

Normalization in SQL | Edureka
Normalization in SQL | EdurekaNormalization in SQL | Edureka
Normalization in SQL | Edureka
 
Normalization
NormalizationNormalization
Normalization
 
Normalization
NormalizationNormalization
Normalization
 
Database Management Systems 4 - Normalization
Database Management Systems 4 - NormalizationDatabase Management Systems 4 - Normalization
Database Management Systems 4 - Normalization
 
Entity relationship diagram - Concept on normalization
Entity relationship diagram - Concept on normalizationEntity relationship diagram - Concept on normalization
Entity relationship diagram - Concept on normalization
 
Normalisation - 2nd normal form
Normalisation - 2nd normal formNormalisation - 2nd normal form
Normalisation - 2nd normal form
 
Database Normalization by Dr. Kamal Gulati
Database Normalization by Dr. Kamal GulatiDatabase Normalization by Dr. Kamal Gulati
Database Normalization by Dr. Kamal Gulati
 
What's database normalization
What's database normalizationWhat's database normalization
What's database normalization
 
Binary Tree in Data Structure
Binary Tree in Data StructureBinary Tree in Data Structure
Binary Tree in Data Structure
 
data structure(tree operations)
data structure(tree operations)data structure(tree operations)
data structure(tree operations)
 
Binary tree and operations
Binary tree and operations Binary tree and operations
Binary tree and operations
 
Ch13 Binary Search Tree
Ch13 Binary Search TreeCh13 Binary Search Tree
Ch13 Binary Search Tree
 
Binary trees
Binary treesBinary trees
Binary trees
 
Database Normalization
Database NormalizationDatabase Normalization
Database Normalization
 
computer notes - Binary tree
computer notes - Binary treecomputer notes - Binary tree
computer notes - Binary tree
 
Intro To TSQL - Unit 4
Intro To TSQL - Unit 4Intro To TSQL - Unit 4
Intro To TSQL - Unit 4
 
Binary tree
Binary treeBinary tree
Binary tree
 
ISDD Database Structure N5
ISDD Database Structure N5ISDD Database Structure N5
ISDD Database Structure N5
 
Dbms 4NF & 5NF
Dbms 4NF & 5NFDbms 4NF & 5NF
Dbms 4NF & 5NF
 
computer notes - Binary search tree
computer notes - Binary search treecomputer notes - Binary search tree
computer notes - Binary search tree
 

Viewers also liked

sql statements & joins
sql statements & joinssql statements & joins
sql statements & joinsSafva AP
 
Introduction to sql database on azure
Introduction to sql database on azureIntroduction to sql database on azure
Introduction to sql database on azureAntonios Chatzipavlis
 
Importance of Normalization
Importance of NormalizationImportance of Normalization
Importance of NormalizationShwe Yee
 
Database Normalization
Database NormalizationDatabase Normalization
Database NormalizationRathan Raj
 
Normalization
NormalizationNormalization
Normalizationochesing
 
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NFDatabase Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NFOum Saokosal
 
Oracle Sql Tuning
Oracle Sql TuningOracle Sql Tuning
Oracle Sql TuningChris Adkin
 
ER model to Relational model mapping
ER model to Relational model mappingER model to Relational model mapping
ER model to Relational model mappingShubham Saini
 
Database design & Normalization (1NF, 2NF, 3NF)
Database design & Normalization (1NF, 2NF, 3NF)Database design & Normalization (1NF, 2NF, 3NF)
Database design & Normalization (1NF, 2NF, 3NF)Jargalsaikhan Alyeksandr
 
ER DIAGRAM TO RELATIONAL SCHEMA MAPPING
ER DIAGRAM TO RELATIONAL SCHEMA MAPPING ER DIAGRAM TO RELATIONAL SCHEMA MAPPING
ER DIAGRAM TO RELATIONAL SCHEMA MAPPING ARADHYAYANA
 

Viewers also liked (14)

sql statements & joins
sql statements & joinssql statements & joins
sql statements & joins
 
Xml material
Xml materialXml material
Xml material
 
Introduction to sql database on azure
Introduction to sql database on azureIntroduction to sql database on azure
Introduction to sql database on azure
 
Importance of Normalization
Importance of NormalizationImportance of Normalization
Importance of Normalization
 
Database Normalization
Database NormalizationDatabase Normalization
Database Normalization
 
Normalization
NormalizationNormalization
Normalization
 
DBMS - Normalization
DBMS - NormalizationDBMS - Normalization
DBMS - Normalization
 
Databases: Normalisation
Databases: NormalisationDatabases: Normalisation
Databases: Normalisation
 
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NFDatabase Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
 
Oracle Sql Tuning
Oracle Sql TuningOracle Sql Tuning
Oracle Sql Tuning
 
ER model to Relational model mapping
ER model to Relational model mappingER model to Relational model mapping
ER model to Relational model mapping
 
Database design & Normalization (1NF, 2NF, 3NF)
Database design & Normalization (1NF, 2NF, 3NF)Database design & Normalization (1NF, 2NF, 3NF)
Database design & Normalization (1NF, 2NF, 3NF)
 
ER DIAGRAM TO RELATIONAL SCHEMA MAPPING
ER DIAGRAM TO RELATIONAL SCHEMA MAPPING ER DIAGRAM TO RELATIONAL SCHEMA MAPPING
ER DIAGRAM TO RELATIONAL SCHEMA MAPPING
 
Slideshare ppt
Slideshare pptSlideshare ppt
Slideshare ppt
 

Similar to Karan normalization in sql

Normalization form tutorial
Normalization form tutorialNormalization form tutorial
Normalization form tutorialNikhildas P C
 
Relational Theory for Budding Einsteins -- LonestarPHP 2016
Relational Theory for Budding Einsteins -- LonestarPHP 2016Relational Theory for Budding Einsteins -- LonestarPHP 2016
Relational Theory for Budding Einsteins -- LonestarPHP 2016Dave Stokes
 
Advance Sqlite3
Advance Sqlite3Advance Sqlite3
Advance Sqlite3Raghu nath
 
Dependencies in various topics like normalisation and its types
Dependencies in various topics like normalisation and its typesDependencies in various topics like normalisation and its types
Dependencies in various topics like normalisation and its typesnsrChowdary1
 
Normalization: A Workshop for Everybody Pt. 2
Normalization: A Workshop for Everybody Pt. 2Normalization: A Workshop for Everybody Pt. 2
Normalization: A Workshop for Everybody Pt. 2Command Prompt., Inc
 
introduction to trees,graphs,hashing
introduction to trees,graphs,hashingintroduction to trees,graphs,hashing
introduction to trees,graphs,hashingAkhil Prem
 
Database Normalization
Database NormalizationDatabase Normalization
Database NormalizationArun Sharma
 
Intro to Data warehousing Lecture 04
Intro to Data warehousing   Lecture 04Intro to Data warehousing   Lecture 04
Intro to Data warehousing Lecture 04AnwarrChaudary
 
Advanced Normalization
Advanced NormalizationAdvanced Normalization
Advanced NormalizationAbdullah Khosa
 
Structured system analysis and design
Structured system analysis and design Structured system analysis and design
Structured system analysis and design Jayant Dalvi
 
How Do We Solve The World's Spreadsheet Problem? - Velocity NY 2018
How Do We Solve The World's Spreadsheet Problem? - Velocity NY 2018How Do We Solve The World's Spreadsheet Problem? - Velocity NY 2018
How Do We Solve The World's Spreadsheet Problem? - Velocity NY 2018Alex Rasmussen
 
denormalization.ppt
denormalization.pptdenormalization.ppt
denormalization.pptABUSUFYAN55
 
overview of database concept
overview of database conceptoverview of database concept
overview of database conceptgourav kottawar
 
Database normalization
Database normalizationDatabase normalization
Database normalizationJignesh Jain
 

Similar to Karan normalization in sql (20)

Database Normalization.pptx
Database Normalization.pptxDatabase Normalization.pptx
Database Normalization.pptx
 
Normalization form tutorial
Normalization form tutorialNormalization form tutorial
Normalization form tutorial
 
Relational Theory for Budding Einsteins -- LonestarPHP 2016
Relational Theory for Budding Einsteins -- LonestarPHP 2016Relational Theory for Budding Einsteins -- LonestarPHP 2016
Relational Theory for Budding Einsteins -- LonestarPHP 2016
 
Year 11 DATA PROCESSING 1st Term
Year 11 DATA PROCESSING 1st TermYear 11 DATA PROCESSING 1st Term
Year 11 DATA PROCESSING 1st Term
 
Normalization
NormalizationNormalization
Normalization
 
Advance Sqlite3
Advance Sqlite3Advance Sqlite3
Advance Sqlite3
 
Dependencies in various topics like normalisation and its types
Dependencies in various topics like normalisation and its typesDependencies in various topics like normalisation and its types
Dependencies in various topics like normalisation and its types
 
Normalization: A Workshop for Everybody Pt. 2
Normalization: A Workshop for Everybody Pt. 2Normalization: A Workshop for Everybody Pt. 2
Normalization: A Workshop for Everybody Pt. 2
 
T-SQL Overview
T-SQL OverviewT-SQL Overview
T-SQL Overview
 
introduction to trees,graphs,hashing
introduction to trees,graphs,hashingintroduction to trees,graphs,hashing
introduction to trees,graphs,hashing
 
Database Normalization
Database NormalizationDatabase Normalization
Database Normalization
 
Unit 3 dbms
Unit 3 dbmsUnit 3 dbms
Unit 3 dbms
 
Intro to Data warehousing Lecture 04
Intro to Data warehousing   Lecture 04Intro to Data warehousing   Lecture 04
Intro to Data warehousing Lecture 04
 
Advanced Normalization
Advanced NormalizationAdvanced Normalization
Advanced Normalization
 
Structured system analysis and design
Structured system analysis and design Structured system analysis and design
Structured system analysis and design
 
How Do We Solve The World's Spreadsheet Problem? - Velocity NY 2018
How Do We Solve The World's Spreadsheet Problem? - Velocity NY 2018How Do We Solve The World's Spreadsheet Problem? - Velocity NY 2018
How Do We Solve The World's Spreadsheet Problem? - Velocity NY 2018
 
denormalization.ppt
denormalization.pptdenormalization.ppt
denormalization.ppt
 
Research gadot
Research gadotResearch gadot
Research gadot
 
overview of database concept
overview of database conceptoverview of database concept
overview of database concept
 
Database normalization
Database normalizationDatabase normalization
Database normalization
 

Recently uploaded

Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 

Recently uploaded (20)

E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 

Karan normalization in sql

  • 1. Normalization BY, Karan R. Kotecha
  • 2. Database Normalization  Database normalization is the process of removing redundant data from your tables in to improve storage efficiency, data integrity, and scalability.  In the relational model, methods exist for quantifying how efficient a database is. These classifications are called normal forms (or NF), and there are algorithms for converting a given database between them.  Normalization generally involves splitting existing tables into multiple ones, which must be re-joined or linked each time a query is issued.
  • 3. History  Edgar F. Codd first proposed the process of normalization and what came to be known as the 1st normal form in his paper A Relational Model of Data for Large Shared Data Banks Codd stated: “There is, in fact, a very simple elimination procedure which we shall call normalization. Through decomposition nonsimple domains are replaced by „domains whose elements are atomic (nondecomposable) values.’”
  • 4. Normal Form  Edgar F. Codd originally established three normal forms: 1NF, 2NF and 3NF. There are now others that are generally accepted, but 3NF is widely considered to be sufficient for most applications. Most tables when reaching 3NF are also in BCNF (Boyce-Codd Normal Form).
  • 5. Table 1 Title Author1 Author ISBN Subject Pages Publisher 2 Database Abraham Henry F. 0072958863 MySQL, 1168 McGraw-Hill System Silberschatz Korth Computers Concepts Operating Abraham Henry F. 0471694665 Computers 944 McGraw-Hill System Silberschatz Korth Concepts
  • 6. Table 1 problems  This table is not very efficient with storage.  This design does not protect data integrity.  Third, this table does not scale well.
  • 7. First Normal Form  In our Table 1, we have two violations of First Normal Form:  First, we have more than one author field,  Second, our subject field contains more than one piece of information. With more than one value in a single field, it would be very difficult to search for all books on a given subject.
  • 8. First Normal Table  Table 2 Title Author ISBN Subject Pages Publisher Database System Abraham 0072958863 MySQL 1168 McGraw-Hill Concepts Silberschatz Database System Henry F. Korth 0072958863 Computers 1168 McGraw-Hill Concepts Operating System Henry F. Korth 0471694665 Computers 944 McGraw-Hill Concepts Operating System Abraham 0471694665 Computers 944 McGraw-Hill Concepts Silberschatz
  • 9.  We now have two rows for a single book. Additionally, we would be violating the Second Normal Form…  A better solution to our problem would be to separate the data into separate tables- an Author table and a Subject table to store our information, removing that information from the Book table:
  • 10. Subject Table Subject_ID Subject 1 MySQL 2 Computers Author Table Author_ID Last Name First Name 1 Silberschatz Abraham 2 Korth Henry Book Table ISBN Title Pages Publisher 0072958863 Database System 1168 McGraw-Hill Concepts 0471694665 Operating System 944 McGraw-Hill Concepts
  • 11.  Each table has a primary key, used for joining tables together when querying the data. A primary key value must be unique with in the table (no two books can have the same ISBN number), and a primary key is also an index, which speeds up data retrieval based on the primary key.  Now to define relationships between the tables
  • 12. Relationships Book_Author Table Book_Subject Table ISBN Author_ID 0072958863 1 ISBN Subject_ID 0072958863 2 0072958863 1 0471694665 1 0072958863 2 0471694665 2 0471694665 2
  • 13. Second Normal Form  As the First Normal Form deals with redundancy of data across a horizontal row, Second Normal Form (or 2NF) deals with redundancy of data in vertical columns.  As stated earlier, the normal forms are progressive, so to achieve Second Normal Form, the tables must already be in First Normal Form.  The Book Table will be used for the 2NF example
  • 14. 2NF Table Publisher Table Publisher_ID Publisher Name 1 McGraw-Hill Book Table ISBN Title Pages Publisher_ID 0072958863 Database System 1168 1 Concepts 0471694665 Operating System 944 1 Concepts
  • 15. 2NF  Here we have a one-to-many relationship between the book table and the publisher. A book has only one publisher, and a publisher will publish many books. When we have a one-to- many relationship, we place a foreign key in the Book Table, pointing to the primary key of the Publisher Table.  The other requirement for Second Normal Form is that you cannot have any data in a table with a composite key that does not relate to all portions of the composite key.
  • 16. Third Normal Form  Third normal form (3NF) requires that there are no functional dependencies of non-key attributes on something other than a candidate key.  A table is in 3NF if all of the non-primary key attributes are mutually independent  There should not be transitive dependencies
  • 17. Boyce-Codd Normal Form  BCNF requires that the table is 3NF and only determinants are the candidate keys
  • 18. Fourth Normal Form (4NF) 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.
  • 19.
  • 20.
  • 21. 5th Normal Form The 5th Normal Form is a “projection-based normalization approach where every nontrivial join dependency is implied by a candidate key”. In the previous example, I showed how one table became two, reducing the risk of data anomalies. 5th normal form could split a single table into three or more. Let‟s say you have a table with store, supplier, and products. The table contains a row for each store, which is repeated for each supplier the store uses, and again for each product that the supplier provides to the particular store (A store might not sell all the products that a supplier provides). All fields in this table are valuable and necessary to represent the row and is in 4th Normal Form. In fact, this is a common type of table that could represent a many-to-many-to-many relationship among stores, products, and suppliers. But, notice that there is repeating data:
  • 22.
  • 23.
  • 24. When a store picks up a new supplier, a new row is added to the store_to_supp table, eliminating the redundancy of extra rows for product. When a store sells a new product, the supp_to_prod table will let you know where to get it. A simple example, yes — but it demonstrates 5th normal form.