SlideShare a Scribd company logo
1 of 30
Download to read offline
DATABASE BASICS
Student
id integer
name string
address string
What is a database key?
Any attribute in a
table which
uniquely identifies
each record.
Database key
Person
id integer
licence_number integer
passport_number integer
name string
Student
id integer
name string
address string
Single & Combined attributes
Combined attributes
Single attribute
Order No Product ID Product Name Quantity
B005 JAP102459 Mouse 5
B005 DKT321573 USB 10
B005 OMG446789 LCD Monitor 20
B004 DKT321573 USB 15
B002 OMG446789 Laser Printer 3
Super Key
Super Key
A non-minimal Candidate
Key, that is to say one with
additional columns not
strictly required to ensure
uniqueness of the row.
Primary, Unique, Alternate
keys are subset of Super Key.
Student
id integer
name string
address string
Primary Key
Primary Key
The first and
foremost key which
is used to uniquely
identify a record
Person
id integer
licence_number integer
passport_number integer
name string
Alternate Key
Alternate Key
All the keys
which are not
primary keys.
Person
id integer
licence_number integer
passport_number integer
name string
Candidate(Secondary) Key
Candidate Key
Is defined as the set of
fields from which primary
key can be selected. A
super key with no
repeated attribute.
Stud ID Roll No First Name Last Name Email
1 11 Tom Price abc@gmail.com
2 12 Nick Wright xyz@gmail.com
3 13 Dana Natan mno@gmail.com
Candidate Key
Alternate KeyPrimary Key
Student
id integer
name string
address string
department_id integer
Department
id integer
name string
Building_number integer
Foreign Key
Foreign Key
Is a column which is added
to create a relationship
with another table.
Primary Key
Order No Product ID Product Name Quantity
B005 JAP102459 Mouse 5
B005 DKT321573 USB 10
B005 OMG446789 LCD Monitor 20
B004 DKT321573 USB 15
B002 OMG446789 Laser Printer 3
Compound(Composite) Key
Compound Key
Has many fields which allow you
to uniquely recognize a specific
record. The difference between
compound and the compositekey
is that any part of the compound
key can be a foreign key, but the
composite key may or maybe not
a part of the foreign key.
Natural Key vs Surrogate Key
A natural key is made up of
naturally occurring fields in
the table. A surrogate key is a
meaningless value added to
uniquely identify a row.
Usually this is an identity or
‘autonumber’ column.
ID First Name Last Name
1 John Doe
2 Jane Austen
3 David Copperfield
Surrogate Key
Surrogate Key
An artificial key which
aims to uniquely
identify each record.
Normalization
•Normalization is a database design technique which
organizes tables in a manner that reduces
redundancy and dependency of data.
•It divides larger tables to smaller tables and links
them using relationships.
1st Normal
Form
2nd Normal
Form
3rd Normal
Form
Boyce-Codd
NF
4th Normal
Form
5th Normal
Form
6th Normal
Form
First Normal Form (1NF) Rules
•Each table cell should contain a single value.
•Each record needs to be unique.
First Normal Form (1NF)
Product ID Color Price
1 black, red 10
2 green 20
3 red 40
4 green, blue 30
5 white 50
This table is not in
first normal form
because the Color
column contains
multiple values.
After decomposing
ProductID Color
1 black
1 red
2 green
3 red
4 green
4 blue
5 white
ProductID Price
1 10
2 20
3 40
4 30
5 50
Second Normal Form (2NF) Rules
•Be in 1NF
•Single Column Primary Key
Second Normal Form (2NF)
CustomerID Store ID Location
1 1 New York
1 3 London
2 1 New York
3 2 Washington
4 3 London
This table has a
composite primary
key(customerid, store
id). The non key
attribute(location)
depends on part of the
primary key(store id).
Store ID Location
1 New York
2 Washington
3 London
After decomposing
Customer ID Store ID
1 1
1 3
2 1
3 2
4 3
Third Normal Form (3NF) Rules
•Be in 2NF
•Has no transitive functional dependencies
Book ID Genre ID Genre Type Price
1 1 Fiction 100
2 2 Sports 110
3 1 Fiction 120
4 3 Travel 130
5 2 Sports 140
In the table Book ID
determines Genre ID, which
determines Genre Type.
Therefore Book ID
determines Genre Type via
Genre ID (transitive functional
dependency).
Third Normal Form (3NF)
After decomposing
Book ID Genre ID Price
1 1 100
2 2 110
3 1 120
4 3 130
5 2 140
Genre ID Genre Type
1 Fiction
2 Sports
3 Travel
Boyce-Codd Normal Form
(BCNF or 3.5 NF) Rules
•Be in 3NF
•For every functional dependency a->b a
should be super key(or candidate) of a table
Boyce-Codd Normal Form
(BCNF or 3.5 NF)
Student Course Teacher
Annie Laravel Greg
Antony Laravel John
David Yii Brian
James Yii Brian
Sara Laravel John
In the table Student
determines Course, which
determines Teacher. Course is
not a Super Key. So we need
to decompose the table to
have BCNF.
Course Teacher
Laravel Greg
Laravel John
Yii Brian
After decomposing
Student Course
Annie Laravel
Antony Laravel
David Yii
James Yii
Sara Laravel
Forth Normal Form (4NF) Rules
Eliminates independent many-to-one
relationships between columns.
•Be in BCNF
•A given relation may not contain more than
one multivalued attributes.
Student Subject Activity
100 Music Swimming
100 Accounting Swimming
100 Music Tennis
100 Accounting Tennis
150 Programming Yoga
In the table for Student are
multiple Subjects and
Activities. Therefore this is
not in 4NF.
Forth Normal Form (4NF)
Student Activity
100 Swimming
100 Tennis
150 Yoga
After decomposing
Student Subject
100 Music
100 Accounting
150 Programming
Fifth and Sixth Normal Forms
(5NF, 6NF)
• A table is in 5th Normal Form only if it is in 4NF and it cannot be
decomposed into any number of smaller tables without loss of
data.
• 6th Normal Form is not standardized, yet however, it is being
discussed by database experts for some time. Hopefully, we
would have a clear & standardized definition for 6th Normal
Form in the near future...
ThankYou!!!

More Related Content

What's hot

Crafting winning strategies in a mature market - US wine market
Crafting winning strategies in a mature market - US wine marketCrafting winning strategies in a mature market - US wine market
Crafting winning strategies in a mature market - US wine market
Saurabh Arora
 
Garanti bank final
Garanti bank finalGaranti bank final
Garanti bank final
mfatatah
 

What's hot (15)

Bank of America : Mobile Banking
Bank of America : Mobile BankingBank of America : Mobile Banking
Bank of America : Mobile Banking
 
Gino sa distribution channel management case study
Gino sa distribution channel management case studyGino sa distribution channel management case study
Gino sa distribution channel management case study
 
Howard schultz : building starbucks community
Howard schultz   : building starbucks communityHoward schultz   : building starbucks community
Howard schultz : building starbucks community
 
Crafting winning strategies in a mature market - US wine market
Crafting winning strategies in a mature market - US wine marketCrafting winning strategies in a mature market - US wine market
Crafting winning strategies in a mature market - US wine market
 
Product management case study ciba vision
Product management case study ciba visionProduct management case study ciba vision
Product management case study ciba vision
 
TruEarth Healthy Food
TruEarth Healthy FoodTruEarth Healthy Food
TruEarth Healthy Food
 
Karnataka PGCET MCA 2017 Answer Key
Karnataka PGCET MCA 2017 Answer KeyKarnataka PGCET MCA 2017 Answer Key
Karnataka PGCET MCA 2017 Answer Key
 
Case study 4
Case study 4Case study 4
Case study 4
 
The credit department of Lion’s Department Store in Anaheim.docx
The credit department of Lion’s Department Store in Anaheim.docxThe credit department of Lion’s Department Store in Anaheim.docx
The credit department of Lion’s Department Store in Anaheim.docx
 
Markstrat Simulation Game - using Segmentation, Targeting, and Positioning
Markstrat Simulation Game - using Segmentation, Targeting, and PositioningMarkstrat Simulation Game - using Segmentation, Targeting, and Positioning
Markstrat Simulation Game - using Segmentation, Targeting, and Positioning
 
Nestle 4Ps challenge 2018 Case Competition PPT - Campus Winners
Nestle 4Ps challenge 2018 Case Competition PPT - Campus WinnersNestle 4Ps challenge 2018 Case Competition PPT - Campus Winners
Nestle 4Ps challenge 2018 Case Competition PPT - Campus Winners
 
P&G Case Study
P&G Case StudyP&G Case Study
P&G Case Study
 
Guaranty Trust Bank financial report 2011
Guaranty Trust Bank financial report 2011Guaranty Trust Bank financial report 2011
Guaranty Trust Bank financial report 2011
 
Idea
IdeaIdea
Idea
 
Garanti bank final
Garanti bank finalGaranti bank final
Garanti bank final
 

Similar to Database Basics

Sql basics joi ns and common commands (1)
Sql basics  joi ns and common commands (1)Sql basics  joi ns and common commands (1)
Sql basics joi ns and common commands (1)
johnnygoodman
 

Similar to Database Basics (15)

Normalization in DBMS
Normalization in DBMSNormalization in DBMS
Normalization in DBMS
 
1-161103092724 (1).pdf
1-161103092724 (1).pdf1-161103092724 (1).pdf
1-161103092724 (1).pdf
 
1-161103092724.pptx
1-161103092724.pptx1-161103092724.pptx
1-161103092724.pptx
 
Solid schemas & advanced sql
Solid schemas & advanced sqlSolid schemas & advanced sql
Solid schemas & advanced sql
 
Relational_Model.ppt
Relational_Model.pptRelational_Model.ppt
Relational_Model.ppt
 
Normalisation revision
Normalisation revisionNormalisation revision
Normalisation revision
 
Types of keys in database | SQL
Types of keys in database | SQLTypes of keys in database | SQL
Types of keys in database | SQL
 
Presentation OF DBMS-2.pptx
Presentation OF DBMS-2.pptxPresentation OF DBMS-2.pptx
Presentation OF DBMS-2.pptx
 
SQL to NoSQL Best Practices with Amazon DynamoDB - AWS July 2016 Webinar Se...
SQL to NoSQL   Best Practices with Amazon DynamoDB - AWS July 2016 Webinar Se...SQL to NoSQL   Best Practices with Amazon DynamoDB - AWS July 2016 Webinar Se...
SQL to NoSQL Best Practices with Amazon DynamoDB - AWS July 2016 Webinar Se...
 
data Normalization.pdf
data Normalization.pdfdata Normalization.pdf
data Normalization.pdf
 
Types of normalization
Types of normalizationTypes of normalization
Types of normalization
 
Database Theory
Database TheoryDatabase Theory
Database Theory
 
Normalization
NormalizationNormalization
Normalization
 
Sql basics joi ns and common commands (1)
Sql basics  joi ns and common commands (1)Sql basics  joi ns and common commands (1)
Sql basics joi ns and common commands (1)
 
It's Not You. It's Your Data Model.
It's Not You. It's Your Data Model.It's Not You. It's Your Data Model.
It's Not You. It's Your Data Model.
 

Recently uploaded

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 

Recently uploaded (20)

fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 

Database Basics

  • 2. Student id integer name string address string What is a database key? Any attribute in a table which uniquely identifies each record. Database key
  • 3. Person id integer licence_number integer passport_number integer name string Student id integer name string address string Single & Combined attributes Combined attributes Single attribute
  • 4. Order No Product ID Product Name Quantity B005 JAP102459 Mouse 5 B005 DKT321573 USB 10 B005 OMG446789 LCD Monitor 20 B004 DKT321573 USB 15 B002 OMG446789 Laser Printer 3 Super Key Super Key A non-minimal Candidate Key, that is to say one with additional columns not strictly required to ensure uniqueness of the row. Primary, Unique, Alternate keys are subset of Super Key.
  • 5. Student id integer name string address string Primary Key Primary Key The first and foremost key which is used to uniquely identify a record
  • 6. Person id integer licence_number integer passport_number integer name string Alternate Key Alternate Key All the keys which are not primary keys.
  • 7. Person id integer licence_number integer passport_number integer name string Candidate(Secondary) Key Candidate Key Is defined as the set of fields from which primary key can be selected. A super key with no repeated attribute.
  • 8. Stud ID Roll No First Name Last Name Email 1 11 Tom Price abc@gmail.com 2 12 Nick Wright xyz@gmail.com 3 13 Dana Natan mno@gmail.com Candidate Key Alternate KeyPrimary Key
  • 9. Student id integer name string address string department_id integer Department id integer name string Building_number integer Foreign Key Foreign Key Is a column which is added to create a relationship with another table. Primary Key
  • 10. Order No Product ID Product Name Quantity B005 JAP102459 Mouse 5 B005 DKT321573 USB 10 B005 OMG446789 LCD Monitor 20 B004 DKT321573 USB 15 B002 OMG446789 Laser Printer 3 Compound(Composite) Key Compound Key Has many fields which allow you to uniquely recognize a specific record. The difference between compound and the compositekey is that any part of the compound key can be a foreign key, but the composite key may or maybe not a part of the foreign key.
  • 11. Natural Key vs Surrogate Key A natural key is made up of naturally occurring fields in the table. A surrogate key is a meaningless value added to uniquely identify a row. Usually this is an identity or ‘autonumber’ column.
  • 12. ID First Name Last Name 1 John Doe 2 Jane Austen 3 David Copperfield Surrogate Key Surrogate Key An artificial key which aims to uniquely identify each record.
  • 13. Normalization •Normalization is a database design technique which organizes tables in a manner that reduces redundancy and dependency of data. •It divides larger tables to smaller tables and links them using relationships. 1st Normal Form 2nd Normal Form 3rd Normal Form Boyce-Codd NF 4th Normal Form 5th Normal Form 6th Normal Form
  • 14. First Normal Form (1NF) Rules •Each table cell should contain a single value. •Each record needs to be unique.
  • 15. First Normal Form (1NF) Product ID Color Price 1 black, red 10 2 green 20 3 red 40 4 green, blue 30 5 white 50 This table is not in first normal form because the Color column contains multiple values.
  • 16. After decomposing ProductID Color 1 black 1 red 2 green 3 red 4 green 4 blue 5 white ProductID Price 1 10 2 20 3 40 4 30 5 50
  • 17. Second Normal Form (2NF) Rules •Be in 1NF •Single Column Primary Key
  • 18. Second Normal Form (2NF) CustomerID Store ID Location 1 1 New York 1 3 London 2 1 New York 3 2 Washington 4 3 London This table has a composite primary key(customerid, store id). The non key attribute(location) depends on part of the primary key(store id).
  • 19. Store ID Location 1 New York 2 Washington 3 London After decomposing Customer ID Store ID 1 1 1 3 2 1 3 2 4 3
  • 20. Third Normal Form (3NF) Rules •Be in 2NF •Has no transitive functional dependencies
  • 21. Book ID Genre ID Genre Type Price 1 1 Fiction 100 2 2 Sports 110 3 1 Fiction 120 4 3 Travel 130 5 2 Sports 140 In the table Book ID determines Genre ID, which determines Genre Type. Therefore Book ID determines Genre Type via Genre ID (transitive functional dependency). Third Normal Form (3NF)
  • 22. After decomposing Book ID Genre ID Price 1 1 100 2 2 110 3 1 120 4 3 130 5 2 140 Genre ID Genre Type 1 Fiction 2 Sports 3 Travel
  • 23. Boyce-Codd Normal Form (BCNF or 3.5 NF) Rules •Be in 3NF •For every functional dependency a->b a should be super key(or candidate) of a table
  • 24. Boyce-Codd Normal Form (BCNF or 3.5 NF) Student Course Teacher Annie Laravel Greg Antony Laravel John David Yii Brian James Yii Brian Sara Laravel John In the table Student determines Course, which determines Teacher. Course is not a Super Key. So we need to decompose the table to have BCNF.
  • 25. Course Teacher Laravel Greg Laravel John Yii Brian After decomposing Student Course Annie Laravel Antony Laravel David Yii James Yii Sara Laravel
  • 26. Forth Normal Form (4NF) Rules Eliminates independent many-to-one relationships between columns. •Be in BCNF •A given relation may not contain more than one multivalued attributes.
  • 27. Student Subject Activity 100 Music Swimming 100 Accounting Swimming 100 Music Tennis 100 Accounting Tennis 150 Programming Yoga In the table for Student are multiple Subjects and Activities. Therefore this is not in 4NF. Forth Normal Form (4NF)
  • 28. Student Activity 100 Swimming 100 Tennis 150 Yoga After decomposing Student Subject 100 Music 100 Accounting 150 Programming
  • 29. Fifth and Sixth Normal Forms (5NF, 6NF) • A table is in 5th Normal Form only if it is in 4NF and it cannot be decomposed into any number of smaller tables without loss of data. • 6th Normal Form is not standardized, yet however, it is being discussed by database experts for some time. Hopefully, we would have a clear & standardized definition for 6th Normal Form in the near future...