SlideShare une entreprise Scribd logo
1  sur  28
For Business Analysts
Database Basics
Database Management System
Why do we need Databases
To Store Data
To Read Data
Update Data
Delete Data
Why buy expensive DBMS
Store information in Excel
Why use database system?
Database Management System
Benefits
Multi user access.
Fast Data Access - Optimized algorithms.
Can survive system CRASH - Disaster recovery.
Multistep operations - Transaction support.
Advance security features.
Data consistency – rules for data structure
Allows indexing
DBMS and Databases
Different Types of DBMS
Hierarchical Database
Object Oriented Databases
Network Databases
Relational Databases
Different DBMS available in the marketplace
SQL Server
Oracle
DB2
MySQL
Database & DBMS relationship
Data Storage
Data is stored in TABLES
All major business entities may have their own
tables
Customer
Supplier
Products
Orders
Columns defines type-of-data, length-of-data
Each row uniquely identifies a customer, product,
or suppliers.
Table Structure
Primary Key
Unique identifier for a
row
Must contain a value
Unique Key
Uniquely defines a row
Can be NULL.
Name Address Phone Income
Paul Milpitas 408-102-
1111
55,000
Sam Fremont 510-102-
2222
85,000
Paul San Jose 95,000
Cust ID
1001
1002
1003
Common Terminology
Name Address Phone Income
Table = Relation
Row = Tuple
Column = Attribute = Field
Cardinality = Number of tuples
Degree = Number of attributes
Domain = Set of legal values for an attribute, for example
Gender attribute may have two legal values male/female
Normalization
Bad Design
Normalization
Anomalies
Insert
Modify
Delete
Normalization
What is normalization?
Split tables using specific rules to reduce
redundancy and avoid anomalies
Splitting tables may result in a performance hit while
accessing data.
Aim is to strike a balance between performance and
redundancy.
Example –
Highly Normalized structure may be used for applications
involving lot of transactions and/or complex transactions –
banking systems
Read only type of applications need not be highly
Normalized - websites
Normalization – 1nf
1st Normal Form
A relation is in 1nf if every attribute is atomic (not a
set or list)
Ord ID Date Time Location Amt $ Items
100 1/1/11 00:30 D101 12.25 Milk, Bread, Eggs
101 2/1/11 06:30 D025 725.7
5
Juice, iPad
102 3/1/11 12:30 D107 5.00 Shampoo, Soap
103 4/1/11 01:30 D022 18.50 Ink cartridge
104 5/1/11 02:30 D101 25.00 Banana, Oranges,
Milk
Normalization – 1nf
Ord ID Item
100 Milk
100 Bread
100 Eggs
101 Juice
101 iPad
103 Shampoo
103 Soap
104 Banana
104 Orange
104 Milk
Ord ID Date Time Location Amt $
100 1/1/11 00:30 D101 12.25
101 2/1/11 06:30 D025 725.7
5
102 3/1/11 12:30 D107 5.00
103 4/1/11 01:30 D022 18.50
104 5/1/11 02:30 D101 25.00
Composite P-
Key
1st Normal Form
- Eliminate repeating groups in individual
tables.
- Create a separate table for each set of
related data.
- Identify each set of related data with a
primary key.
Normalization – 1nf
Name City Phones 1 Phone 2
Sam Fremont 510-200-3000 NULL
Tom Concord 925-373-1212 925-255-1010
Bob Milpitas 408-408-2121 408-233-4545
Name City
Sam Fremont
Tom Concord
Bob Milpitas
Name Phone
Sam 510-200-3000
Tom 925-373-1212
Tom 925-255-1010
Bob 408-408-2121
Bob 408-233-4545
Normalization
2nd Normal Form
A relation is in 2NF if every non-prime attribute is
non-partially dependent on the Primary Key.
Relation meets 1NF
R. No Course # Course Grade
R100 C001 Maths A
R101 C002 Chem B+
R101 C003 Physics C
Normalization
3rd Normal Form
Normalization
Other Normal forms
Database Design
Data Flow Diagram (DFD)
Database Design
Common Design Patterns
Hierarchy
Master Detail
Registration
Lookups
Order
Common Flags
IsActive?
IsDeleted?
Data Access
DDL – Data Definition Language
Create, Alter, Drop, Truncate, Rename etc.
DCL – Data Control Language
Grant, Revoke
DML – Data Modification Language
Insert, Update, Delete etc.
DQL – Data Query Language
Select
SQL - Basic
Simple Selects (using single table)
Concept of ALIAS
Where Clause
Operators
SQL - Basic
Understand Grouping and Aggregation
Understand Having Clause
Difference between Having and Where
Understand NULL
Condition translates to Boolean true/false
SQL - Basic
Example – Simple Select with NULLs and
Aggregates
SQL - Joins
Link back to Normalization
Loss Less Join
SQL - Joins
Join using Where Clause
Understand Cartesian Product
Join Syntax
Write queries
SQL - Joins
Self Join
Types of JOINS
Inner Joins
Left Outer Join
Right Outer Join
Write queries
SQL - Transactions
ACID properties
Show transactions
Set Operations
Union
Intersection etc.
Write queries
Aggregations
Country
Aggregated
Data
Rule 1 - Column that is displayed AS-IS must
be added to the GROUP BY clause
Rule 2 – All other columns should be part of
AGGREGATE functions

Contenu connexe

Tendances

Data warehouse architecture
Data warehouse architectureData warehouse architecture
Data warehouse architecturepcherukumalla
 
Database Normalization
Database NormalizationDatabase Normalization
Database NormalizationArun Sharma
 
Relational Database Design
Relational Database DesignRelational Database Design
Relational Database DesignArchit Saxena
 
Database Relationships
Database RelationshipsDatabase Relationships
Database Relationshipswmassie
 
Data Modeling PPT
Data Modeling PPTData Modeling PPT
Data Modeling PPTTrinath
 
data modeling and models
data modeling and modelsdata modeling and models
data modeling and modelssabah N
 
Database Design
Database DesignDatabase Design
Database Designlearnt
 
Database backup and recovery
Database backup and recoveryDatabase backup and recovery
Database backup and recoveryAnne Lee
 
Dbms Introduction and Basics
Dbms Introduction and BasicsDbms Introduction and Basics
Dbms Introduction and BasicsSHIKHA GAUTAM
 
11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMS11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMSkoolkampus
 
File systems versus a dbms
File systems versus a dbmsFile systems versus a dbms
File systems versus a dbmsRituBhargava7
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraintsmadhav bansal
 

Tendances (20)

Data warehouse architecture
Data warehouse architectureData warehouse architecture
Data warehouse architecture
 
Database Normalization
Database NormalizationDatabase Normalization
Database Normalization
 
Relational Database Design
Relational Database DesignRelational Database Design
Relational Database Design
 
Database Relationships
Database RelationshipsDatabase Relationships
Database Relationships
 
MySQL ppt
MySQL ppt MySQL ppt
MySQL ppt
 
Dbms
DbmsDbms
Dbms
 
Introduction to sql
Introduction to sqlIntroduction to sql
Introduction to sql
 
NOSQL vs SQL
NOSQL vs SQLNOSQL vs SQL
NOSQL vs SQL
 
Data Modeling PPT
Data Modeling PPTData Modeling PPT
Data Modeling PPT
 
data modeling and models
data modeling and modelsdata modeling and models
data modeling and models
 
Database Design
Database DesignDatabase Design
Database Design
 
Database backup and recovery
Database backup and recoveryDatabase backup and recovery
Database backup and recovery
 
Dbms Introduction and Basics
Dbms Introduction and BasicsDbms Introduction and Basics
Dbms Introduction and Basics
 
11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMS11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMS
 
database
databasedatabase
database
 
DBMS
DBMSDBMS
DBMS
 
File systems versus a dbms
File systems versus a dbmsFile systems versus a dbms
File systems versus a dbms
 
Data dictionary
Data dictionaryData dictionary
Data dictionary
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraints
 
Oracle SQL Basics
Oracle SQL BasicsOracle SQL Basics
Oracle SQL Basics
 

Similaire à Database basics

Data Analysis using Data Flux
Data Analysis using Data FluxData Analysis using Data Flux
Data Analysis using Data FluxSunil Pai
 
Lecture 18
Lecture 18Lecture 18
Lecture 18Shani729
 
Ibm Optim Techical Overview 01282009
Ibm Optim Techical Overview 01282009Ibm Optim Techical Overview 01282009
Ibm Optim Techical Overview 01282009lucascibm
 
Implementing Change Systems in SQL Server 2016
Implementing Change Systems in SQL Server 2016Implementing Change Systems in SQL Server 2016
Implementing Change Systems in SQL Server 2016Douglas McClurg
 
When & Why\'s of Denormalization
When & Why\'s of DenormalizationWhen & Why\'s of Denormalization
When & Why\'s of DenormalizationAliya Saldanha
 
Optim test data management for IMS 2011
Optim test data management for IMS 2011Optim test data management for IMS 2011
Optim test data management for IMS 2011evgeni77
 
Intro to Database Design
Intro to Database DesignIntro to Database Design
Intro to Database DesignSondra Willhite
 
Database Management System
Database Management SystemDatabase Management System
Database Management SystemAbishek V S
 
PPT SQL CLASS.pptx
PPT SQL CLASS.pptxPPT SQL CLASS.pptx
PPT SQL CLASS.pptxAngeOuattara
 
Intro to Data warehousing lecture 10
Intro to Data warehousing   lecture 10Intro to Data warehousing   lecture 10
Intro to Data warehousing lecture 10AnwarrChaudary
 
Datawarehousing & DSS
Datawarehousing & DSSDatawarehousing & DSS
Datawarehousing & DSSDeepali Raut
 
CQRS introduction
CQRS introductionCQRS introduction
CQRS introductionYura Taras
 
Data base testing
Data base testingData base testing
Data base testingBugRaptors
 

Similaire à Database basics (20)

4.Database Management System.pdf
4.Database Management System.pdf4.Database Management System.pdf
4.Database Management System.pdf
 
Data Analysis using Data Flux
Data Analysis using Data FluxData Analysis using Data Flux
Data Analysis using Data Flux
 
Lecture 18
Lecture 18Lecture 18
Lecture 18
 
Ibm Optim Techical Overview 01282009
Ibm Optim Techical Overview 01282009Ibm Optim Techical Overview 01282009
Ibm Optim Techical Overview 01282009
 
Implementing Change Systems in SQL Server 2016
Implementing Change Systems in SQL Server 2016Implementing Change Systems in SQL Server 2016
Implementing Change Systems in SQL Server 2016
 
When & Why\'s of Denormalization
When & Why\'s of DenormalizationWhen & Why\'s of Denormalization
When & Why\'s of Denormalization
 
Optim test data management for IMS 2011
Optim test data management for IMS 2011Optim test data management for IMS 2011
Optim test data management for IMS 2011
 
Intro to Database Design
Intro to Database DesignIntro to Database Design
Intro to Database Design
 
Database Management System
Database Management SystemDatabase Management System
Database Management System
 
PPT SQL CLASS.pptx
PPT SQL CLASS.pptxPPT SQL CLASS.pptx
PPT SQL CLASS.pptx
 
SOA the Oracle way
SOA the Oracle waySOA the Oracle way
SOA the Oracle way
 
Intro to Data warehousing lecture 10
Intro to Data warehousing   lecture 10Intro to Data warehousing   lecture 10
Intro to Data warehousing lecture 10
 
ITReady DW Day2
ITReady DW Day2ITReady DW Day2
ITReady DW Day2
 
Database
DatabaseDatabase
Database
 
Datawarehousing & DSS
Datawarehousing & DSSDatawarehousing & DSS
Datawarehousing & DSS
 
Lecture 3 note.pptx
Lecture 3 note.pptxLecture 3 note.pptx
Lecture 3 note.pptx
 
CQRS introduction
CQRS introductionCQRS introduction
CQRS introduction
 
Data base testing
Data base testingData base testing
Data base testing
 
Teradata a z
Teradata a zTeradata a z
Teradata a z
 
Sql Server 2000
Sql Server 2000Sql Server 2000
Sql Server 2000
 

Dernier

Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default  Presentation : Data Analysis Project PPTPredictive Analysis for Loan Default  Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPTBoston Institute of Analytics
 
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDINTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDRafezzaman
 
Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 217djon017
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort servicejennyeacort
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Jack DiGiovanna
 
Semantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptxSemantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptxMike Bennett
 
Predicting Salary Using Data Science: A Comprehensive Analysis.pdf
Predicting Salary Using Data Science: A Comprehensive Analysis.pdfPredicting Salary Using Data Science: A Comprehensive Analysis.pdf
Predicting Salary Using Data Science: A Comprehensive Analysis.pdfBoston Institute of Analytics
 
NLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptx
NLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptxNLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptx
NLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptxBoston Institute of Analytics
 
Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...Seán Kennedy
 
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...dajasot375
 
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024thyngster
 
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...Florian Roscheck
 
20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdfHuman37
 
How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFAAndrei Kaleshka
 
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理e4aez8ss
 
Identifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population MeanIdentifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population MeanMYRABACSAFRA2
 
Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024Colleen Farrelly
 
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一F sss
 
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)jennyeacort
 
Data Factory in Microsoft Fabric (MsBIP #82)
Data Factory in Microsoft Fabric (MsBIP #82)Data Factory in Microsoft Fabric (MsBIP #82)
Data Factory in Microsoft Fabric (MsBIP #82)Cathrine Wilhelmsen
 

Dernier (20)

Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default  Presentation : Data Analysis Project PPTPredictive Analysis for Loan Default  Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
 
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDINTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
 
Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
 
Semantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptxSemantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptx
 
Predicting Salary Using Data Science: A Comprehensive Analysis.pdf
Predicting Salary Using Data Science: A Comprehensive Analysis.pdfPredicting Salary Using Data Science: A Comprehensive Analysis.pdf
Predicting Salary Using Data Science: A Comprehensive Analysis.pdf
 
NLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptx
NLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptxNLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptx
NLP Project PPT: Flipkart Product Reviews through NLP Data Science.pptx
 
Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...
 
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
 
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
 
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
 
20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf
 
How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFA
 
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
 
Identifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population MeanIdentifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population Mean
 
Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024
 
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
 
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
 
Data Factory in Microsoft Fabric (MsBIP #82)
Data Factory in Microsoft Fabric (MsBIP #82)Data Factory in Microsoft Fabric (MsBIP #82)
Data Factory in Microsoft Fabric (MsBIP #82)
 

Database basics

  • 2. Database Management System Why do we need Databases To Store Data To Read Data Update Data Delete Data Why buy expensive DBMS Store information in Excel
  • 3. Why use database system? Database Management System Benefits Multi user access. Fast Data Access - Optimized algorithms. Can survive system CRASH - Disaster recovery. Multistep operations - Transaction support. Advance security features. Data consistency – rules for data structure Allows indexing
  • 4. DBMS and Databases Different Types of DBMS Hierarchical Database Object Oriented Databases Network Databases Relational Databases Different DBMS available in the marketplace SQL Server Oracle DB2 MySQL Database & DBMS relationship
  • 5. Data Storage Data is stored in TABLES All major business entities may have their own tables Customer Supplier Products Orders Columns defines type-of-data, length-of-data Each row uniquely identifies a customer, product, or suppliers.
  • 6. Table Structure Primary Key Unique identifier for a row Must contain a value Unique Key Uniquely defines a row Can be NULL. Name Address Phone Income Paul Milpitas 408-102- 1111 55,000 Sam Fremont 510-102- 2222 85,000 Paul San Jose 95,000 Cust ID 1001 1002 1003
  • 7. Common Terminology Name Address Phone Income Table = Relation Row = Tuple Column = Attribute = Field Cardinality = Number of tuples Degree = Number of attributes Domain = Set of legal values for an attribute, for example Gender attribute may have two legal values male/female
  • 10. Normalization What is normalization? Split tables using specific rules to reduce redundancy and avoid anomalies Splitting tables may result in a performance hit while accessing data. Aim is to strike a balance between performance and redundancy. Example – Highly Normalized structure may be used for applications involving lot of transactions and/or complex transactions – banking systems Read only type of applications need not be highly Normalized - websites
  • 11. Normalization – 1nf 1st Normal Form A relation is in 1nf if every attribute is atomic (not a set or list) Ord ID Date Time Location Amt $ Items 100 1/1/11 00:30 D101 12.25 Milk, Bread, Eggs 101 2/1/11 06:30 D025 725.7 5 Juice, iPad 102 3/1/11 12:30 D107 5.00 Shampoo, Soap 103 4/1/11 01:30 D022 18.50 Ink cartridge 104 5/1/11 02:30 D101 25.00 Banana, Oranges, Milk
  • 12. Normalization – 1nf Ord ID Item 100 Milk 100 Bread 100 Eggs 101 Juice 101 iPad 103 Shampoo 103 Soap 104 Banana 104 Orange 104 Milk Ord ID Date Time Location Amt $ 100 1/1/11 00:30 D101 12.25 101 2/1/11 06:30 D025 725.7 5 102 3/1/11 12:30 D107 5.00 103 4/1/11 01:30 D022 18.50 104 5/1/11 02:30 D101 25.00 Composite P- Key 1st Normal Form - Eliminate repeating groups in individual tables. - Create a separate table for each set of related data. - Identify each set of related data with a primary key.
  • 13. Normalization – 1nf Name City Phones 1 Phone 2 Sam Fremont 510-200-3000 NULL Tom Concord 925-373-1212 925-255-1010 Bob Milpitas 408-408-2121 408-233-4545 Name City Sam Fremont Tom Concord Bob Milpitas Name Phone Sam 510-200-3000 Tom 925-373-1212 Tom 925-255-1010 Bob 408-408-2121 Bob 408-233-4545
  • 14. Normalization 2nd Normal Form A relation is in 2NF if every non-prime attribute is non-partially dependent on the Primary Key. Relation meets 1NF R. No Course # Course Grade R100 C001 Maths A R101 C002 Chem B+ R101 C003 Physics C
  • 17. Database Design Data Flow Diagram (DFD)
  • 18. Database Design Common Design Patterns Hierarchy Master Detail Registration Lookups Order Common Flags IsActive? IsDeleted?
  • 19. Data Access DDL – Data Definition Language Create, Alter, Drop, Truncate, Rename etc. DCL – Data Control Language Grant, Revoke DML – Data Modification Language Insert, Update, Delete etc. DQL – Data Query Language Select
  • 20. SQL - Basic Simple Selects (using single table) Concept of ALIAS Where Clause Operators
  • 21. SQL - Basic Understand Grouping and Aggregation Understand Having Clause Difference between Having and Where Understand NULL Condition translates to Boolean true/false
  • 22. SQL - Basic Example – Simple Select with NULLs and Aggregates
  • 23. SQL - Joins Link back to Normalization Loss Less Join
  • 24. SQL - Joins Join using Where Clause Understand Cartesian Product Join Syntax Write queries
  • 25. SQL - Joins Self Join Types of JOINS Inner Joins Left Outer Join Right Outer Join Write queries
  • 26. SQL - Transactions ACID properties Show transactions
  • 28. Aggregations Country Aggregated Data Rule 1 - Column that is displayed AS-IS must be added to the GROUP BY clause Rule 2 – All other columns should be part of AGGREGATE functions