SlideShare ist ein Scribd-Unternehmen logo
1 von 31
Where Are My Keys? Ami Levin | CTO | DBSophic LTD
Session Goals A revisit to some of the fundamental design principals of relational databases: Normalization rules, key selection, and the controversies associated with these issues from a very practical, hands-on perspective, with special emphasis on some surprising performance issues that may arise from sub-optimal selection of keys...
The Forefathers
Normalization “A relation whose domains are all simple can be represented in storage by a two-dimensional column homogeneous array of the kind discussed above. Some more complicated data structure is necessary for a relation with one or more non-simple domains. For this reason (and others to be cited below) the possibility of eliminating non-simple domains appears worth investigating. There is, in fact, a very simple elimination procedure, which we shall call
 normalization”
1st Normal Form There's no top-to-bottom or left-to-right ordering to the rows and columns There are no duplicate rows Every row-column intersection contains exactly one value All columns are regular
1st Normal Form
2nd Normal Form R is in 1st Normal Form (1NF). Given any candidate key K and any attribute A that is not a constituent of a candidate key, A depends upon the whole of K rather than just a part of it.
2nd Normal Form
3rd Normal Form R is in second normal form (2NF) Every non-prime attribute of R is non-transitively dependent on every candidate key of R. A transitive dependency is a functional dependency, in which X -> Z (X determines Z) indirectly, by virtue of X -> Y and Y -> Z.
3rd Normal Form
Keys Simple Composite 	 Candidate 	 Primary	 Artificial / Surrogate 	 Intelligent Natural
The Debate To ID or not to ID? IDENTITY (1,1) PK vs. Natural key
Pro Artificial In some cases, no natural key exists and an artificial key is the only option. Examples?
Pro Artificial Natural keys can change. Artificial keys never change. How Often? Cascading referential constraints Artificial keys can change
Pro Artificial Natural keys may become very long and complex. Get longer with each level 900 Bytes limit in SQL Server Multi-column Joins
Pro Artificial Artificial keys improve performance.  Simpler join predicates Ever increasing clustering effect Short keys = Smaller DB = Faster (?)
Pro Artificial Artificial keys reduce clustered index fragmentation.  All types of artificial keys? Minimize maintenance down time What about deletes? What about non-clustered indexes?
Pro Natural Natural keys have business meaning. Artificial keys are logically never queried for
Pro Natural Queries on tables using natural keys require fewer joins. The more familiar and meaningful the key, the less joins are required “Bypass” joins across levels
Pro Natural Data consistency is maintained explicitly when using natural keys. Artificial keys enable logical duplicates
Pro Natural Natural keys eliminate potential physical clustering performance issues. Contention for clustered regions
Less Mentioned Issues Artificial keys are the de-facto standard. ORM generate artificial keys LINQ doesn’t cache composite key rows
Less Mentioned Issues Data statistics and optimizations. Statistics on artificial keys are useless for parameter sniffing Selectivity estimations on composite key statistics are less accurate
Less Mentioned Issues Modularity and portability. Migration to other platforms Merging with other databases
Less Mentioned Issues Simplicity and aesthetics.
Demo Design Spec URL Country and city of owner Country ISO code needed by application Data consistency is crucial
Natural vs. Artificial DEMO
Ask Yourself
 Is there a natural key that I can use as PK?  Are there a few natural candidates?  Which one is the simplest and most familiar? How stable is it? How will it be used logically? What will be the table physical usage patterns? What are the common query types for this table?
For More Information A Relational Model of Data for Large Shared Data Banksby E. F. CODD. The Relational Model for Database Management: Version 2 by E.F. Codd.  An introduction to database systemsby C.J Date.  Database in Depth: Relational Theory for Practitionersby C.J Date. The Database Relational Model: A Retrospective Review and Analysisby C.J Date. Joe Celko's Data and Databases: Concepts in Practice by Joe Celko. Joe Celko's SQL for Smarties, Fourth Edition: Advanced SQL Programmingby Joe Celko. Database Modeling and Design, Fifth Edition: Logical Designby Toby J. Teorey, Sam S. Lightstone, Tom Nadeau, and H.V. Jagadish. Pro SQL Server 2008 Relational Database Design and Implementationby Louis Davidson, Kevin Kline, Scott Klein, and Kurt Windisch.
Where Are My Keys? Q&A
3   where are my keys - sql explore

Weitere Àhnliche Inhalte

Was ist angesagt?

Database Design and Normalization
Database Design and NormalizationDatabase Design and Normalization
Database Design and NormalizationDave Kelleher
 
Concept Based Search
Concept Based SearchConcept Based Search
Concept Based Searchfreewi11
 
Relational Databases 2
Relational Databases 2Relational Databases 2
Relational Databases 2Jason Hando
 
Effective Unsupervised Matching of Product Titles
Effective Unsupervised Matching of Product TitlesEffective Unsupervised Matching of Product Titles
Effective Unsupervised Matching of Product TitlesLeonidas Akritidis
 
Zhongyuan Zhu - 2015 - Evaluating Neural Machine Translation in English-Japan...
Zhongyuan Zhu - 2015 - Evaluating Neural Machine Translation in English-Japan...Zhongyuan Zhu - 2015 - Evaluating Neural Machine Translation in English-Japan...
Zhongyuan Zhu - 2015 - Evaluating Neural Machine Translation in English-Japan...Association for Computational Linguistics
 
SystemT: Declarative Information Extraction
SystemT: Declarative Information ExtractionSystemT: Declarative Information Extraction
SystemT: Declarative Information ExtractionYunyao Li
 
Object relationship mapping and hibernate
Object relationship mapping and hibernateObject relationship mapping and hibernate
Object relationship mapping and hibernateJoe Jacob
 
Wipro technical interview questions
Wipro technical interview questionsWipro technical interview questions
Wipro technical interview questionsPoonam Kherde
 

Was ist angesagt? (16)

Notesparadigms
NotesparadigmsNotesparadigms
Notesparadigms
 
Database Design and Normalization
Database Design and NormalizationDatabase Design and Normalization
Database Design and Normalization
 
D4 Introduction to LINQ
D4 Introduction to LINQD4 Introduction to LINQ
D4 Introduction to LINQ
 
Concept Based Search
Concept Based SearchConcept Based Search
Concept Based Search
 
Dbms
DbmsDbms
Dbms
 
Relational Databases 2
Relational Databases 2Relational Databases 2
Relational Databases 2
 
Prolog ppt
Prolog pptProlog ppt
Prolog ppt
 
Computer sec2-1st term
Computer sec2-1st termComputer sec2-1st term
Computer sec2-1st term
 
Effective Unsupervised Matching of Product Titles
Effective Unsupervised Matching of Product TitlesEffective Unsupervised Matching of Product Titles
Effective Unsupervised Matching of Product Titles
 
Sec 2 1st term rev.
Sec 2  1st term rev.Sec 2  1st term rev.
Sec 2 1st term rev.
 
Zhongyuan Zhu - 2015 - Evaluating Neural Machine Translation in English-Japan...
Zhongyuan Zhu - 2015 - Evaluating Neural Machine Translation in English-Japan...Zhongyuan Zhu - 2015 - Evaluating Neural Machine Translation in English-Japan...
Zhongyuan Zhu - 2015 - Evaluating Neural Machine Translation in English-Japan...
 
Specs2
Specs2Specs2
Specs2
 
SystemT: Declarative Information Extraction
SystemT: Declarative Information ExtractionSystemT: Declarative Information Extraction
SystemT: Declarative Information Extraction
 
Object relationship mapping and hibernate
Object relationship mapping and hibernateObject relationship mapping and hibernate
Object relationship mapping and hibernate
 
Wipro technical interview questions
Wipro technical interview questionsWipro technical interview questions
Wipro technical interview questions
 
Er Modeling
Er ModelingEr Modeling
Er Modeling
 

Andere mochten auch

3 extreme performance - databases acceleration using ssd
3   extreme performance - databases acceleration using ssd 3   extreme performance - databases acceleration using ssd
3 extreme performance - databases acceleration using ssd sqlserver.co.il
 
Products.intro.forum version
Products.intro.forum versionProducts.intro.forum version
Products.intro.forum versionsqlserver.co.il
 
SQL Explore 2012: P&T Part 3
SQL Explore 2012: P&T Part 3SQL Explore 2012: P&T Part 3
SQL Explore 2012: P&T Part 3sqlserver.co.il
 
Adi Sapir ISUG 123 11/10/2012
Adi Sapir ISUG 123 11/10/2012Adi Sapir ISUG 123 11/10/2012
Adi Sapir ISUG 123 11/10/2012sqlserver.co.il
 
Query handlingbytheserver
Query handlingbytheserverQuery handlingbytheserver
Query handlingbytheserversqlserver.co.il
 
Sql server user group news january 2013
Sql server user group news   january 2013Sql server user group news   january 2013
Sql server user group news january 2013sqlserver.co.il
 
Things you can find in the plan cache
Things you can find in the plan cacheThings you can find in the plan cache
Things you can find in the plan cachesqlserver.co.il
 
Windows azure sql_database_security_isug012013
Windows azure sql_database_security_isug012013Windows azure sql_database_security_isug012013
Windows azure sql_database_security_isug012013sqlserver.co.il
 

Andere mochten auch (9)

3 extreme performance - databases acceleration using ssd
3   extreme performance - databases acceleration using ssd 3   extreme performance - databases acceleration using ssd
3 extreme performance - databases acceleration using ssd
 
Products.intro.forum version
Products.intro.forum versionProducts.intro.forum version
Products.intro.forum version
 
SQL Explore 2012: P&T Part 3
SQL Explore 2012: P&T Part 3SQL Explore 2012: P&T Part 3
SQL Explore 2012: P&T Part 3
 
DAC 2012
DAC 2012DAC 2012
DAC 2012
 
Adi Sapir ISUG 123 11/10/2012
Adi Sapir ISUG 123 11/10/2012Adi Sapir ISUG 123 11/10/2012
Adi Sapir ISUG 123 11/10/2012
 
Query handlingbytheserver
Query handlingbytheserverQuery handlingbytheserver
Query handlingbytheserver
 
Sql server user group news january 2013
Sql server user group news   january 2013Sql server user group news   january 2013
Sql server user group news january 2013
 
Things you can find in the plan cache
Things you can find in the plan cacheThings you can find in the plan cache
Things you can find in the plan cache
 
Windows azure sql_database_security_isug012013
Windows azure sql_database_security_isug012013Windows azure sql_database_security_isug012013
Windows azure sql_database_security_isug012013
 

Ähnlich wie 3 where are my keys - sql explore

Most frequently asked infosys technical interview questions and answers in 2018
Most frequently asked infosys technical interview questions and answers in 2018Most frequently asked infosys technical interview questions and answers in 2018
Most frequently asked infosys technical interview questions and answers in 2018nishajj
 
Avoiding common database pitfalls
Avoiding common database pitfallsAvoiding common database pitfalls
Avoiding common database pitfallsDerek Binkley
 
NLIDB(Natural Language Interface to DataBases)
NLIDB(Natural Language Interface to DataBases)NLIDB(Natural Language Interface to DataBases)
NLIDB(Natural Language Interface to DataBases)Swetha Pallati
 
Domain oriented development
Domain oriented developmentDomain oriented development
Domain oriented developmentrajmundr
 
Dare to build vertical design with relational data (Entity-Attribute-Value)
Dare to build vertical design with relational data (Entity-Attribute-Value)Dare to build vertical design with relational data (Entity-Attribute-Value)
Dare to build vertical design with relational data (Entity-Attribute-Value)Ivo Andreev
 
Prague data management meetup 2016-11-22
Prague data management meetup 2016-11-22Prague data management meetup 2016-11-22
Prague data management meetup 2016-11-22Martin BĂ©m
 
Finding your Way in the Midst of the NoSQL Haze - Abdelmonaim Remani
Finding your Way in the Midst of the NoSQL Haze - Abdelmonaim RemaniFinding your Way in the Midst of the NoSQL Haze - Abdelmonaim Remani
Finding your Way in the Midst of the NoSQL Haze - Abdelmonaim RemaniJAXLondon2014
 
01 Persistence And Orm
01 Persistence And Orm01 Persistence And Orm
01 Persistence And OrmRanjan Kumar
 
Mc0077 – advanced database systems
Mc0077 – advanced database systemsMc0077 – advanced database systems
Mc0077 – advanced database systemsRabby Bhatt
 
Cts informatica interview question answers
Cts informatica interview question answersCts informatica interview question answers
Cts informatica interview question answersSweta Singh
 
Intelligent query converter a domain independent interfacefor conversion
Intelligent query converter a domain independent interfacefor conversionIntelligent query converter a domain independent interfacefor conversion
Intelligent query converter a domain independent interfacefor conversionIAEME Publication
 
The Importance of Data Analysis in Producing a Robust Physical Data Model
The Importance of Data Analysis in Producing a Robust Physical Data ModelThe Importance of Data Analysis in Producing a Robust Physical Data Model
The Importance of Data Analysis in Producing a Robust Physical Data ModelDeclan Chellar
 
2006 DDD4: Data access layers - Convenience vs. Control and Performance?
2006 DDD4: Data access layers - Convenience vs. Control and Performance?2006 DDD4: Data access layers - Convenience vs. Control and Performance?
2006 DDD4: Data access layers - Convenience vs. Control and Performance?Daniel Fisher
 
Elegant and Efficient Database Design
Elegant and Efficient Database DesignElegant and Efficient Database Design
Elegant and Efficient Database DesignBecky Sweger
 
Why you shouldnt use django for that
Why you shouldnt use django for thatWhy you shouldnt use django for that
Why you shouldnt use django for thatIvĂĄn Stepaniuk
 
2. Relational_Data_Model_Keys_10b.pptx
2. Relational_Data_Model_Keys_10b.pptx2. Relational_Data_Model_Keys_10b.pptx
2. Relational_Data_Model_Keys_10b.pptxvidyahulkman
 
Lecture 13
Lecture 13Lecture 13
Lecture 13Shani729
 
The Joy Of Functional Programming
The Joy Of Functional ProgrammingThe Joy Of Functional Programming
The Joy Of Functional Programmingjasondew
 
Performance By Design
Performance By DesignPerformance By Design
Performance By DesignGuy Harrison
 

Ähnlich wie 3 where are my keys - sql explore (20)

Most frequently asked infosys technical interview questions and answers in 2018
Most frequently asked infosys technical interview questions and answers in 2018Most frequently asked infosys technical interview questions and answers in 2018
Most frequently asked infosys technical interview questions and answers in 2018
 
Avoiding common database pitfalls
Avoiding common database pitfallsAvoiding common database pitfalls
Avoiding common database pitfalls
 
Rdbms
RdbmsRdbms
Rdbms
 
NLIDB(Natural Language Interface to DataBases)
NLIDB(Natural Language Interface to DataBases)NLIDB(Natural Language Interface to DataBases)
NLIDB(Natural Language Interface to DataBases)
 
Domain oriented development
Domain oriented developmentDomain oriented development
Domain oriented development
 
Dare to build vertical design with relational data (Entity-Attribute-Value)
Dare to build vertical design with relational data (Entity-Attribute-Value)Dare to build vertical design with relational data (Entity-Attribute-Value)
Dare to build vertical design with relational data (Entity-Attribute-Value)
 
Prague data management meetup 2016-11-22
Prague data management meetup 2016-11-22Prague data management meetup 2016-11-22
Prague data management meetup 2016-11-22
 
Finding your Way in the Midst of the NoSQL Haze - Abdelmonaim Remani
Finding your Way in the Midst of the NoSQL Haze - Abdelmonaim RemaniFinding your Way in the Midst of the NoSQL Haze - Abdelmonaim Remani
Finding your Way in the Midst of the NoSQL Haze - Abdelmonaim Remani
 
01 Persistence And Orm
01 Persistence And Orm01 Persistence And Orm
01 Persistence And Orm
 
Mc0077 – advanced database systems
Mc0077 – advanced database systemsMc0077 – advanced database systems
Mc0077 – advanced database systems
 
Cts informatica interview question answers
Cts informatica interview question answersCts informatica interview question answers
Cts informatica interview question answers
 
Intelligent query converter a domain independent interfacefor conversion
Intelligent query converter a domain independent interfacefor conversionIntelligent query converter a domain independent interfacefor conversion
Intelligent query converter a domain independent interfacefor conversion
 
The Importance of Data Analysis in Producing a Robust Physical Data Model
The Importance of Data Analysis in Producing a Robust Physical Data ModelThe Importance of Data Analysis in Producing a Robust Physical Data Model
The Importance of Data Analysis in Producing a Robust Physical Data Model
 
2006 DDD4: Data access layers - Convenience vs. Control and Performance?
2006 DDD4: Data access layers - Convenience vs. Control and Performance?2006 DDD4: Data access layers - Convenience vs. Control and Performance?
2006 DDD4: Data access layers - Convenience vs. Control and Performance?
 
Elegant and Efficient Database Design
Elegant and Efficient Database DesignElegant and Efficient Database Design
Elegant and Efficient Database Design
 
Why you shouldnt use django for that
Why you shouldnt use django for thatWhy you shouldnt use django for that
Why you shouldnt use django for that
 
2. Relational_Data_Model_Keys_10b.pptx
2. Relational_Data_Model_Keys_10b.pptx2. Relational_Data_Model_Keys_10b.pptx
2. Relational_Data_Model_Keys_10b.pptx
 
Lecture 13
Lecture 13Lecture 13
Lecture 13
 
The Joy Of Functional Programming
The Joy Of Functional ProgrammingThe Joy Of Functional Programming
The Joy Of Functional Programming
 
Performance By Design
Performance By DesignPerformance By Design
Performance By Design
 

Mehr von sqlserver.co.il

SQL Explore 2012: P&T Part 2
SQL Explore 2012: P&T Part 2SQL Explore 2012: P&T Part 2
SQL Explore 2012: P&T Part 2sqlserver.co.il
 
SQL Explore 2012: P&T Part 1
SQL Explore 2012: P&T Part 1SQL Explore 2012: P&T Part 1
SQL Explore 2012: P&T Part 1sqlserver.co.il
 
SQL Explore 2012 - Tzahi Hakikat and Keren Bartal: Extended Events
SQL Explore 2012 - Tzahi Hakikat and Keren Bartal: Extended EventsSQL Explore 2012 - Tzahi Hakikat and Keren Bartal: Extended Events
SQL Explore 2012 - Tzahi Hakikat and Keren Bartal: Extended Eventssqlserver.co.il
 
SQL Explore 2012 - Michael Zilberstein: ColumnStore
SQL Explore 2012 - Michael Zilberstein: ColumnStoreSQL Explore 2012 - Michael Zilberstein: ColumnStore
SQL Explore 2012 - Michael Zilberstein: ColumnStoresqlserver.co.il
 
SQL Explore 2012 - Meir Dudai: DAC
SQL Explore 2012 - Meir Dudai: DACSQL Explore 2012 - Meir Dudai: DAC
SQL Explore 2012 - Meir Dudai: DACsqlserver.co.il
 
SQL Explore 2012 - Aviad Deri: Spatial
SQL Explore 2012 - Aviad Deri: SpatialSQL Explore 2012 - Aviad Deri: Spatial
SQL Explore 2012 - Aviad Deri: Spatialsqlserver.co.il
 
ŚžŚ™Ś›ŚŚœ
ŚžŚ™Ś›ŚŚœŚžŚ™Ś›ŚŚœ
ŚžŚ™Ś›ŚŚœsqlserver.co.il
 
ŚžŚ™Ś›ŚŚœ
ŚžŚ™Ś›ŚŚœŚžŚ™Ś›ŚŚœ
ŚžŚ™Ś›ŚŚœsqlserver.co.il
 
Bi303 data warehousing with fast track and pdw - Assaf Fraenkel
Bi303 data warehousing with fast track and pdw - Assaf FraenkelBi303 data warehousing with fast track and pdw - Assaf Fraenkel
Bi303 data warehousing with fast track and pdw - Assaf Fraenkelsqlserver.co.il
 
Fast transition to sql server 2012 from mssql 2005 2008 for developers - Dav...
Fast transition to sql server 2012 from mssql 2005 2008 for  developers - Dav...Fast transition to sql server 2012 from mssql 2005 2008 for  developers - Dav...
Fast transition to sql server 2012 from mssql 2005 2008 for developers - Dav...sqlserver.co.il
 
ISUG 113: File stream
ISUG 113: File streamISUG 113: File stream
ISUG 113: File streamsqlserver.co.il
 
Extreme performance - IDF UG
Extreme performance - IDF UGExtreme performance - IDF UG
Extreme performance - IDF UGsqlserver.co.il
 
3 extreme performance - databases acceleration using ssd
3   extreme performance - databases acceleration using ssd 3   extreme performance - databases acceleration using ssd
3 extreme performance - databases acceleration using ssd sqlserver.co.il
 
4 extreme performance - part ii
4   extreme performance - part ii4   extreme performance - part ii
4 extreme performance - part iisqlserver.co.il
 
2 extreme performance - smaller is better
2   extreme performance - smaller is better2   extreme performance - smaller is better
2 extreme performance - smaller is bettersqlserver.co.il
 
1 extreme performance - part i
1   extreme performance - part i1   extreme performance - part i
1 extreme performance - part isqlserver.co.il
 
6 sql explorer - powershell dba
6   sql explorer - powershell dba6   sql explorer - powershell dba
6 sql explorer - powershell dbasqlserver.co.il
 

Mehr von sqlserver.co.il (20)

SQL Explore 2012: P&T Part 2
SQL Explore 2012: P&T Part 2SQL Explore 2012: P&T Part 2
SQL Explore 2012: P&T Part 2
 
SQL Explore 2012: P&T Part 1
SQL Explore 2012: P&T Part 1SQL Explore 2012: P&T Part 1
SQL Explore 2012: P&T Part 1
 
SQL Explore 2012 - Tzahi Hakikat and Keren Bartal: Extended Events
SQL Explore 2012 - Tzahi Hakikat and Keren Bartal: Extended EventsSQL Explore 2012 - Tzahi Hakikat and Keren Bartal: Extended Events
SQL Explore 2012 - Tzahi Hakikat and Keren Bartal: Extended Events
 
SQL Explore 2012 - Michael Zilberstein: ColumnStore
SQL Explore 2012 - Michael Zilberstein: ColumnStoreSQL Explore 2012 - Michael Zilberstein: ColumnStore
SQL Explore 2012 - Michael Zilberstein: ColumnStore
 
SQL Explore 2012 - Meir Dudai: DAC
SQL Explore 2012 - Meir Dudai: DACSQL Explore 2012 - Meir Dudai: DAC
SQL Explore 2012 - Meir Dudai: DAC
 
SQL Explore 2012 - Aviad Deri: Spatial
SQL Explore 2012 - Aviad Deri: SpatialSQL Explore 2012 - Aviad Deri: Spatial
SQL Explore 2012 - Aviad Deri: Spatial
 
ŚžŚ™Ś›ŚŚœ
ŚžŚ™Ś›ŚŚœŚžŚ™Ś›ŚŚœ
ŚžŚ™Ś›ŚŚœ
 
Ś Ś•ŚąŚ
Ś Ś•ŚąŚŚ Ś•ŚąŚ
Ś Ś•ŚąŚ
 
ŚąŚ“Ś™
ŚąŚ“Ś™ŚąŚ“Ś™
ŚąŚ“Ś™
 
ŚžŚ™Ś›ŚŚœ
ŚžŚ™Ś›ŚŚœŚžŚ™Ś›ŚŚœ
ŚžŚ™Ś›ŚŚœ
 
Bi303 data warehousing with fast track and pdw - Assaf Fraenkel
Bi303 data warehousing with fast track and pdw - Assaf FraenkelBi303 data warehousing with fast track and pdw - Assaf Fraenkel
Bi303 data warehousing with fast track and pdw - Assaf Fraenkel
 
DBCC - Dubi Lebel
DBCC - Dubi LebelDBCC - Dubi Lebel
DBCC - Dubi Lebel
 
Fast transition to sql server 2012 from mssql 2005 2008 for developers - Dav...
Fast transition to sql server 2012 from mssql 2005 2008 for  developers - Dav...Fast transition to sql server 2012 from mssql 2005 2008 for  developers - Dav...
Fast transition to sql server 2012 from mssql 2005 2008 for developers - Dav...
 
ISUG 113: File stream
ISUG 113: File streamISUG 113: File stream
ISUG 113: File stream
 
Extreme performance - IDF UG
Extreme performance - IDF UGExtreme performance - IDF UG
Extreme performance - IDF UG
 
3 extreme performance - databases acceleration using ssd
3   extreme performance - databases acceleration using ssd 3   extreme performance - databases acceleration using ssd
3 extreme performance - databases acceleration using ssd
 
4 extreme performance - part ii
4   extreme performance - part ii4   extreme performance - part ii
4 extreme performance - part ii
 
2 extreme performance - smaller is better
2   extreme performance - smaller is better2   extreme performance - smaller is better
2 extreme performance - smaller is better
 
1 extreme performance - part i
1   extreme performance - part i1   extreme performance - part i
1 extreme performance - part i
 
6 sql explorer - powershell dba
6   sql explorer - powershell dba6   sql explorer - powershell dba
6 sql explorer - powershell dba
 

KĂŒrzlich hochgeladen

DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Christopher Logan Kennedy
 

KĂŒrzlich hochgeladen (20)

DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 

3 where are my keys - sql explore

  • 1. Where Are My Keys? Ami Levin | CTO | DBSophic LTD
  • 2. Session Goals A revisit to some of the fundamental design principals of relational databases: Normalization rules, key selection, and the controversies associated with these issues from a very practical, hands-on perspective, with special emphasis on some surprising performance issues that may arise from sub-optimal selection of keys...
  • 4. Normalization “A relation whose domains are all simple can be represented in storage by a two-dimensional column homogeneous array of the kind discussed above. Some more complicated data structure is necessary for a relation with one or more non-simple domains. For this reason (and others to be cited below) the possibility of eliminating non-simple domains appears worth investigating. There is, in fact, a very simple elimination procedure, which we shall call
 normalization”
  • 5. 1st Normal Form There's no top-to-bottom or left-to-right ordering to the rows and columns There are no duplicate rows Every row-column intersection contains exactly one value All columns are regular
  • 7. 2nd Normal Form R is in 1st Normal Form (1NF). Given any candidate key K and any attribute A that is not a constituent of a candidate key, A depends upon the whole of K rather than just a part of it.
  • 9. 3rd Normal Form R is in second normal form (2NF) Every non-prime attribute of R is non-transitively dependent on every candidate key of R. A transitive dependency is a functional dependency, in which X -> Z (X determines Z) indirectly, by virtue of X -> Y and Y -> Z.
  • 11. Keys Simple Composite Candidate Primary Artificial / Surrogate Intelligent Natural
  • 12. The Debate To ID or not to ID? IDENTITY (1,1) PK vs. Natural key
  • 13. Pro Artificial In some cases, no natural key exists and an artificial key is the only option. Examples?
  • 14. Pro Artificial Natural keys can change. Artificial keys never change. How Often? Cascading referential constraints Artificial keys can change
  • 15. Pro Artificial Natural keys may become very long and complex. Get longer with each level 900 Bytes limit in SQL Server Multi-column Joins
  • 16. Pro Artificial Artificial keys improve performance. Simpler join predicates Ever increasing clustering effect Short keys = Smaller DB = Faster (?)
  • 17. Pro Artificial Artificial keys reduce clustered index fragmentation. All types of artificial keys? Minimize maintenance down time What about deletes? What about non-clustered indexes?
  • 18. Pro Natural Natural keys have business meaning. Artificial keys are logically never queried for
  • 19. Pro Natural Queries on tables using natural keys require fewer joins. The more familiar and meaningful the key, the less joins are required “Bypass” joins across levels
  • 20. Pro Natural Data consistency is maintained explicitly when using natural keys. Artificial keys enable logical duplicates
  • 21. Pro Natural Natural keys eliminate potential physical clustering performance issues. Contention for clustered regions
  • 22. Less Mentioned Issues Artificial keys are the de-facto standard. ORM generate artificial keys LINQ doesn’t cache composite key rows
  • 23. Less Mentioned Issues Data statistics and optimizations. Statistics on artificial keys are useless for parameter sniffing Selectivity estimations on composite key statistics are less accurate
  • 24. Less Mentioned Issues Modularity and portability. Migration to other platforms Merging with other databases
  • 25. Less Mentioned Issues Simplicity and aesthetics.
  • 26. Demo Design Spec URL Country and city of owner Country ISO code needed by application Data consistency is crucial
  • 28. Ask Yourself
 Is there a natural key that I can use as PK? Are there a few natural candidates? Which one is the simplest and most familiar? How stable is it? How will it be used logically? What will be the table physical usage patterns? What are the common query types for this table?
  • 29. For More Information A Relational Model of Data for Large Shared Data Banksby E. F. CODD. The Relational Model for Database Management: Version 2 by E.F. Codd. An introduction to database systemsby C.J Date. Database in Depth: Relational Theory for Practitionersby C.J Date. The Database Relational Model: A Retrospective Review and Analysisby C.J Date. Joe Celko's Data and Databases: Concepts in Practice by Joe Celko. Joe Celko's SQL for Smarties, Fourth Edition: Advanced SQL Programmingby Joe Celko. Database Modeling and Design, Fifth Edition: Logical Designby Toby J. Teorey, Sam S. Lightstone, Tom Nadeau, and H.V. Jagadish. Pro SQL Server 2008 Relational Database Design and Implementationby Louis Davidson, Kevin Kline, Scott Klein, and Kurt Windisch.
  • 30. Where Are My Keys? Q&A