THE KEY TO KEYS - Microsoft...KAREN SAYS: KEYS 1. Keys are Key to performance AND data quality 2....
Transcript of THE KEY TO KEYS - Microsoft...KAREN SAYS: KEYS 1. Keys are Key to performance AND data quality 2....
![Page 1: THE KEY TO KEYS - Microsoft...KAREN SAYS: KEYS 1. Keys are Key to performance AND data quality 2. Concepts can have many ways to implement 3. Not all data modeling vendors use the](https://reader030.fdocuments.in/reader030/viewer/2022040213/5e965d8e93cae91f906c1d02/html5/thumbnails/1.jpg)
Karen Lopez @datachick #TeamData
THE KEY TO KEYSPRIMARY ALTERNATE IDENTITY UNIQUE CLUSTERED SEQUENCE SURROGATE CLUTTERED
FOREIGN MEANINGLESS HASH ROWIDENTIFIER ROWID LOOKUP SEARCH PK FK GUID BUSINESS IDENTIFIER PROPERTY CONSTRAINT INDEX
![Page 2: THE KEY TO KEYS - Microsoft...KAREN SAYS: KEYS 1. Keys are Key to performance AND data quality 2. Concepts can have many ways to implement 3. Not all data modeling vendors use the](https://reader030.fdocuments.in/reader030/viewer/2022040213/5e965d8e93cae91f906c1d02/html5/thumbnails/2.jpg)
![Page 3: THE KEY TO KEYS - Microsoft...KAREN SAYS: KEYS 1. Keys are Key to performance AND data quality 2. Concepts can have many ways to implement 3. Not all data modeling vendors use the](https://reader030.fdocuments.in/reader030/viewer/2022040213/5e965d8e93cae91f906c1d02/html5/thumbnails/3.jpg)
YES, PLEASE DO TWEET/SHARE TODAY’S
EVENT@DATACHICK #TEAMDATA
![Page 4: THE KEY TO KEYS - Microsoft...KAREN SAYS: KEYS 1. Keys are Key to performance AND data quality 2. Concepts can have many ways to implement 3. Not all data modeling vendors use the](https://reader030.fdocuments.in/reader030/viewer/2022040213/5e965d8e93cae91f906c1d02/html5/thumbnails/4.jpg)
KAREN LÓPEZ
Karen has 20+ years of data and information architecture experience on large, multi-project programs.
She is a frequent speaker on data modeling, data-driven methodologies and pattern data models.
She wants you to love your data…
She is loves new tech and gadgets
![Page 5: THE KEY TO KEYS - Microsoft...KAREN SAYS: KEYS 1. Keys are Key to performance AND data quality 2. Concepts can have many ways to implement 3. Not all data modeling vendors use the](https://reader030.fdocuments.in/reader030/viewer/2022040213/5e965d8e93cae91f906c1d02/html5/thumbnails/5.jpg)
WHO ARE YOU?
![Page 6: THE KEY TO KEYS - Microsoft...KAREN SAYS: KEYS 1. Keys are Key to performance AND data quality 2. Concepts can have many ways to implement 3. Not all data modeling vendors use the](https://reader030.fdocuments.in/reader030/viewer/2022040213/5e965d8e93cae91f906c1d02/html5/thumbnails/6.jpg)
So many terms
and jargon in
talking about
database stuff
![Page 7: THE KEY TO KEYS - Microsoft...KAREN SAYS: KEYS 1. Keys are Key to performance AND data quality 2. Concepts can have many ways to implement 3. Not all data modeling vendors use the](https://reader030.fdocuments.in/reader030/viewer/2022040213/5e965d8e93cae91f906c1d02/html5/thumbnails/7.jpg)
WHY THIS TOPIC?
Modeling Vocabulary
Database Vocabulary
Vendor Vocabulary
Slang & Jargon
![Page 8: THE KEY TO KEYS - Microsoft...KAREN SAYS: KEYS 1. Keys are Key to performance AND data quality 2. Concepts can have many ways to implement 3. Not all data modeling vendors use the](https://reader030.fdocuments.in/reader030/viewer/2022040213/5e965d8e93cae91f906c1d02/html5/thumbnails/8.jpg)
KAREN SAYS: KEYS1. Keys are Key to performance
AND data quality
2. Concepts can have many ways to implement
3. Not all data modeling vendors use the same terms
4. Not all database vendors use are the same
If only there
was a
profession that
specialized in
giving thing
standard names
![Page 9: THE KEY TO KEYS - Microsoft...KAREN SAYS: KEYS 1. Keys are Key to performance AND data quality 2. Concepts can have many ways to implement 3. Not all data modeling vendors use the](https://reader030.fdocuments.in/reader030/viewer/2022040213/5e965d8e93cae91f906c1d02/html5/thumbnails/9.jpg)
TODAY’S FOCUS
Entities and Tables
Attributes and Columns
Database objects that implement or enforce key-
related stuff
![Page 10: THE KEY TO KEYS - Microsoft...KAREN SAYS: KEYS 1. Keys are Key to performance AND data quality 2. Concepts can have many ways to implement 3. Not all data modeling vendors use the](https://reader030.fdocuments.in/reader030/viewer/2022040213/5e965d8e93cae91f906c1d02/html5/thumbnails/10.jpg)
ONE MORE THING… KEYS ARE KEY!
Keys (Identifiers) play a role that many modelers & designers forget:
They form part of the semantics of our models.
Primary keys are used in enforcing constraints on data quality
Primary keys are not just about performance.
![Page 11: THE KEY TO KEYS - Microsoft...KAREN SAYS: KEYS 1. Keys are Key to performance AND data quality 2. Concepts can have many ways to implement 3. Not all data modeling vendors use the](https://reader030.fdocuments.in/reader030/viewer/2022040213/5e965d8e93cae91f906c1d02/html5/thumbnails/11.jpg)
Is all about the keys, ‘bout the keys, ‘bout the keys…
Depends on understanding the MEANING of the keys and columns
Goes all to heck* when you have surrogate keys
Depends on the make up of the key parts (columns)
NORMALIZATION
![Page 12: THE KEY TO KEYS - Microsoft...KAREN SAYS: KEYS 1. Keys are Key to performance AND data quality 2. Concepts can have many ways to implement 3. Not all data modeling vendors use the](https://reader030.fdocuments.in/reader030/viewer/2022040213/5e965d8e93cae91f906c1d02/html5/thumbnails/12.jpg)
3NF
Every fact is either part of a key
or depends upon the key, the whole
key, and nothing but the key.….so help you Codd
Michael J Swart
![Page 13: THE KEY TO KEYS - Microsoft...KAREN SAYS: KEYS 1. Keys are Key to performance AND data quality 2. Concepts can have many ways to implement 3. Not all data modeling vendors use the](https://reader030.fdocuments.in/reader030/viewer/2022040213/5e965d8e93cae91f906c1d02/html5/thumbnails/13.jpg)
LINGO, JARGON AND TERMSWE ARE LOUSY AT STANDARDIZING THESE THINGS
![Page 14: THE KEY TO KEYS - Microsoft...KAREN SAYS: KEYS 1. Keys are Key to performance AND data quality 2. Concepts can have many ways to implement 3. Not all data modeling vendors use the](https://reader030.fdocuments.in/reader030/viewer/2022040213/5e965d8e93cae91f906c1d02/html5/thumbnails/14.jpg)
TYPES OF KEY VOCABULARIES
Terms used conceptually
• Primary key
• Alternate key
• Composite key
• Super key
• Candidate key
• Surrogate key
• …
Terms used physically
• Primary key
• Clustered key
• Encryption key
• Partitioning key
• Index
• Identity
• Sequence
![Page 15: THE KEY TO KEYS - Microsoft...KAREN SAYS: KEYS 1. Keys are Key to performance AND data quality 2. Concepts can have many ways to implement 3. Not all data modeling vendors use the](https://reader030.fdocuments.in/reader030/viewer/2022040213/5e965d8e93cae91f906c1d02/html5/thumbnails/15.jpg)
PRIMARY
16
Sequence
Alternate
Composite
CandidateIdentity
Numeric
Lookup
Cluttered
Clustered
Natural
Business
Logical
Encryption
Index
Duplicate
Foreign
Constraint
Partitioning
Super
Unique
Compound
Surrogate
GUID
![Page 16: THE KEY TO KEYS - Microsoft...KAREN SAYS: KEYS 1. Keys are Key to performance AND data quality 2. Concepts can have many ways to implement 3. Not all data modeling vendors use the](https://reader030.fdocuments.in/reader030/viewer/2022040213/5e965d8e93cae91f906c1d02/html5/thumbnails/16.jpg)
AT THE BEGINNING
Business Key
Logical Key Natural Key
![Page 17: THE KEY TO KEYS - Microsoft...KAREN SAYS: KEYS 1. Keys are Key to performance AND data quality 2. Concepts can have many ways to implement 3. Not all data modeling vendors use the](https://reader030.fdocuments.in/reader030/viewer/2022040213/5e965d8e93cae91f906c1d02/html5/thumbnails/17.jpg)
CLOSER TO DESIGN…
Super KeyCandidate
KeyPrimary
KeyAlternate
KeyForeign Key
![Page 18: THE KEY TO KEYS - Microsoft...KAREN SAYS: KEYS 1. Keys are Key to performance AND data quality 2. Concepts can have many ways to implement 3. Not all data modeling vendors use the](https://reader030.fdocuments.in/reader030/viewer/2022040213/5e965d8e93cae91f906c1d02/html5/thumbnails/18.jpg)
PRIMARY KEY CRITERIA
Applicable to all instances (Mandatory)
Unique
Stable
Small
The first two are required by the Relational Model.
3 and 4 required by good practice. But they are not required in data modeling.
Modelers should, however, live in the real world most of the time and observe them
![Page 19: THE KEY TO KEYS - Microsoft...KAREN SAYS: KEYS 1. Keys are Key to performance AND data quality 2. Concepts can have many ways to implement 3. Not all data modeling vendors use the](https://reader030.fdocuments.in/reader030/viewer/2022040213/5e965d8e93cae91f906c1d02/html5/thumbnails/19.jpg)
ALTERNATE KEYS
Unique MandatoryMight
Change
Unique Constraint
Unique Index
![Page 20: THE KEY TO KEYS - Microsoft...KAREN SAYS: KEYS 1. Keys are Key to performance AND data quality 2. Concepts can have many ways to implement 3. Not all data modeling vendors use the](https://reader030.fdocuments.in/reader030/viewer/2022040213/5e965d8e93cae91f906c1d02/html5/thumbnails/20.jpg)
MORE TERMS
Cluttered key
Composite key
Compound key
![Page 21: THE KEY TO KEYS - Microsoft...KAREN SAYS: KEYS 1. Keys are Key to performance AND data quality 2. Concepts can have many ways to implement 3. Not all data modeling vendors use the](https://reader030.fdocuments.in/reader030/viewer/2022040213/5e965d8e93cae91f906c1d02/html5/thumbnails/21.jpg)
MORE TERMS
Surrogate Key
Identity Sequence GUID Custom
![Page 22: THE KEY TO KEYS - Microsoft...KAREN SAYS: KEYS 1. Keys are Key to performance AND data quality 2. Concepts can have many ways to implement 3. Not all data modeling vendors use the](https://reader030.fdocuments.in/reader030/viewer/2022040213/5e965d8e93cae91f906c1d02/html5/thumbnails/22.jpg)
SURROGATE KEYS
![Page 23: THE KEY TO KEYS - Microsoft...KAREN SAYS: KEYS 1. Keys are Key to performance AND data quality 2. Concepts can have many ways to implement 3. Not all data modeling vendors use the](https://reader030.fdocuments.in/reader030/viewer/2022040213/5e965d8e93cae91f906c1d02/html5/thumbnails/23.jpg)
![Page 24: THE KEY TO KEYS - Microsoft...KAREN SAYS: KEYS 1. Keys are Key to performance AND data quality 2. Concepts can have many ways to implement 3. Not all data modeling vendors use the](https://reader030.fdocuments.in/reader030/viewer/2022040213/5e965d8e93cae91f906c1d02/html5/thumbnails/24.jpg)
IDENTITY/IDENTITY PROPERTY
Issue: How people use them
25532,767
9,223,372,036,854,775,807
2,147,483,647
IDENTITY [ (seed , increment) ]
![Page 25: THE KEY TO KEYS - Microsoft...KAREN SAYS: KEYS 1. Keys are Key to performance AND data quality 2. Concepts can have many ways to implement 3. Not all data modeling vendors use the](https://reader030.fdocuments.in/reader030/viewer/2022040213/5e965d8e93cae91f906c1d02/html5/thumbnails/25.jpg)
IDENTITIES
Issue: How people monitor them
IDENTITY [ (seed , increment) ]
AD-322-S
![Page 26: THE KEY TO KEYS - Microsoft...KAREN SAYS: KEYS 1. Keys are Key to performance AND data quality 2. Concepts can have many ways to implement 3. Not all data modeling vendors use the](https://reader030.fdocuments.in/reader030/viewer/2022040213/5e965d8e93cae91f906c1d02/html5/thumbnails/26.jpg)
HOW DO YOU FIX IT IF IT’S ALREADY GONE OFF?
RESEED
GAPS
Not UNIQUE?
Change DataType
![Page 27: THE KEY TO KEYS - Microsoft...KAREN SAYS: KEYS 1. Keys are Key to performance AND data quality 2. Concepts can have many ways to implement 3. Not all data modeling vendors use the](https://reader030.fdocuments.in/reader030/viewer/2022040213/5e965d8e93cae91f906c1d02/html5/thumbnails/27.jpg)
WHAT ABOUT SEQUENCES?
CREATE SEQUENCE [schema_name . ] sequence_name[ AS [ built_in_integer_type | user-defined_integer_type ] ] [ START WITH <constant> ] [ INCREMENT BY <constant> ] [ { MINVALUE [ <constant> ] } | { NOMINVALUE } ]
[ { MAXVALUE [ <constant> ] } | { NOMAXVALUE } ] [ CYCLE | { NOCYCLE } ] [ { CACHE [ <constant> ] } | { NO CACHE } ] [ ; ]
![Page 28: THE KEY TO KEYS - Microsoft...KAREN SAYS: KEYS 1. Keys are Key to performance AND data quality 2. Concepts can have many ways to implement 3. Not all data modeling vendors use the](https://reader030.fdocuments.in/reader030/viewer/2022040213/5e965d8e93cae91f906c1d02/html5/thumbnails/28.jpg)
RESTART
ALTER SEQUENCE [schema_name. ] sequence_name
[ RESTART [ WITH <constant> ] ]
[ INCREMENT BY <constant> ]
[ { MINVALUE <constant> } | { NO MINVALUE } ] [ { MAXVALUE <constant> } | { NO MAXVALUE } ]
[ CYCLE | { NO CYCLE } ] [ { CACHE [ <constant> ] } | { NO CACHE } ]
[ ; ]
AD-322-S
![Page 29: THE KEY TO KEYS - Microsoft...KAREN SAYS: KEYS 1. Keys are Key to performance AND data quality 2. Concepts can have many ways to implement 3. Not all data modeling vendors use the](https://reader030.fdocuments.in/reader030/viewer/2022040213/5e965d8e93cae91f906c1d02/html5/thumbnails/29.jpg)
HOW DO YOU FIX IT IF IT’S ALREADY GONE OFF?
RESTART
GAPS
Not UNIQUE?
Change DataType
![Page 30: THE KEY TO KEYS - Microsoft...KAREN SAYS: KEYS 1. Keys are Key to performance AND data quality 2. Concepts can have many ways to implement 3. Not all data modeling vendors use the](https://reader030.fdocuments.in/reader030/viewer/2022040213/5e965d8e93cae91f906c1d02/html5/thumbnails/30.jpg)
HOW DO YOU PREVENT IT?
Proper Design
Do the math
SEED Value
Increment Value
Use another feature
Monitor
Max allowable value
Max current value
Gaps
Predict* countdown timer
Team Data Script
Know your hottest tables
Prioritize
http://thomaslarock.com/2015/11/sql-server-identity-values-check/
![Page 31: THE KEY TO KEYS - Microsoft...KAREN SAYS: KEYS 1. Keys are Key to performance AND data quality 2. Concepts can have many ways to implement 3. Not all data modeling vendors use the](https://reader030.fdocuments.in/reader030/viewer/2022040213/5e965d8e93cae91f906c1d02/html5/thumbnails/31.jpg)
GUIDS
16 bytes
Universally unique
Many per table
3F2504E0-4F89-41D3-9A0C-0305E82C3301
![Page 32: THE KEY TO KEYS - Microsoft...KAREN SAYS: KEYS 1. Keys are Key to performance AND data quality 2. Concepts can have many ways to implement 3. Not all data modeling vendors use the](https://reader030.fdocuments.in/reader030/viewer/2022040213/5e965d8e93cae91f906c1d02/html5/thumbnails/32.jpg)
MORE TERMS
Numeric Integer BIG IntegerSmall
number
![Page 33: THE KEY TO KEYS - Microsoft...KAREN SAYS: KEYS 1. Keys are Key to performance AND data quality 2. Concepts can have many ways to implement 3. Not all data modeling vendors use the](https://reader030.fdocuments.in/reader030/viewer/2022040213/5e965d8e93cae91f906c1d02/html5/thumbnails/33.jpg)
MORE TERMS
Clustered Key
Partitioning Key
![Page 34: THE KEY TO KEYS - Microsoft...KAREN SAYS: KEYS 1. Keys are Key to performance AND data quality 2. Concepts can have many ways to implement 3. Not all data modeling vendors use the](https://reader030.fdocuments.in/reader030/viewer/2022040213/5e965d8e93cae91f906c1d02/html5/thumbnails/34.jpg)
MORE TERMS
Index ConstraintApplication
codeReferential
Integrity
![Page 35: THE KEY TO KEYS - Microsoft...KAREN SAYS: KEYS 1. Keys are Key to performance AND data quality 2. Concepts can have many ways to implement 3. Not all data modeling vendors use the](https://reader030.fdocuments.in/reader030/viewer/2022040213/5e965d8e93cae91f906c1d02/html5/thumbnails/35.jpg)
HOW EASY IS THIS?
“Just allocate a surrogate key for every table”
Job done.
And why do we need data modelers/designers?
![Page 36: THE KEY TO KEYS - Microsoft...KAREN SAYS: KEYS 1. Keys are Key to performance AND data quality 2. Concepts can have many ways to implement 3. Not all data modeling vendors use the](https://reader030.fdocuments.in/reader030/viewer/2022040213/5e965d8e93cae91f906c1d02/html5/thumbnails/36.jpg)
WHAT YOU SHOULD DO:
Read UpEnsure you use correct
terms
Understand how your
tools create and
generate keys
Learn about the Outliers
Set the standard
for correct term use
![Page 37: THE KEY TO KEYS - Microsoft...KAREN SAYS: KEYS 1. Keys are Key to performance AND data quality 2. Concepts can have many ways to implement 3. Not all data modeling vendors use the](https://reader030.fdocuments.in/reader030/viewer/2022040213/5e965d8e93cae91f906c1d02/html5/thumbnails/37.jpg)
THANK YOU, YOU WERE GREAT.
KAREN LOPEZ @DATACHICK