Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

The Key to Keys - Database Design

581 views

Published on

There are many data modeling and database design terms and jargon that uses the word "key." Do you know the difference between a surrogate key and a primary key? A super key and a candidate key? Could you explain them to a technical audience? A business user or an auditor?

In this presentation, Karen Lopez covers the concepts of primary keys, foreign keys, candidate key, surrogate keys, and more.

Published in: Data & Analytics
  • DOWNLOAD FULL BOOKS INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... 1.DOWNLOAD FULL PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

The Key to Keys - Database Design

  1. 1. Karen Lopez @datachick #TeamData THE KEY TO KEYS PRIMARY ALTERNATE IDENTITY UNIQUE CLUSTERED SEQUENCE SURROGATE CLUTTERED FOREIGN MEANINGLESS HASH ROWIDENTIFIER ROWID LOOKUP SEARCH PK FK GUID BUSINESS IDENTIFIER PROPERTY CONSTRAINT INDEX
  2. 2. Spotthestation.nasa.gov
  3. 3. YES, PLEASE DO TWEET/SHARE TODAY’S EVENT @DATACHICK #TEAMDATA
  4. 4. 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
  5. 5. WHO ARE YOU?
  6. 6. So many terms and jargon in talking about database stuff
  7. 7. WHY THIS TOPIC? Modeling Vocabulary Database Vocabulary Vendor Vocabulary Slang & Jargon
  8. 8. 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 same terms 4. Not all database vendors use are the same If only there was a profession that specialized in giving thing standard names
  9. 9. TODAY’S FOCUS Entities and Tables Attributes and Columns Database objects that implement or enforce key- related stuff
  10. 10. 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.
  11. 11. 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
  12. 12. 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
  13. 13. LINGO, JARGON AND TERMS WE ARE LOUSY AT STANDARDIZING THESE THINGS
  14. 14. 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
  15. 15. PRIMARY 16 Sequence Alternate Composite Candidate Identity Numeric Lookup Cluttered Clustered Natural Business Logical Encryption Index Duplicate Foreign Constraint Partitioning Super Unique Compound Surrogate GUID
  16. 16. AT THE BEGINNING Business Key Logical Key Natural Key
  17. 17. CLOSER TO DESIGN… Super Key Candidate Key Primary Key Alternate Key Foreign Key
  18. 18. 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
  19. 19. ALTERNATE KEYS Unique Mandatory Might Change Unique Constraint Unique Index
  20. 20. MORE TERMS Cluttered key Composite key Compound key
  21. 21. MORE TERMS Surrogate Key Identity Sequence GUID Custom
  22. 22. SURROGATE KEYS
  23. 23. IDENTITY/IDENTITY PROPERTY Issue: How people use them 255 32,767 9,223,372,036,854,775,807 2,147,483,647 IDENTITY [ (seed , increment) ]
  24. 24. IDENTITIES Issue: How people monitor them IDENTITY [ (seed , increment) ] AD-322-S
  25. 25. HOW DO YOU FIX IT IF IT’S ALREADY GONE OFF? RESEED GAPS Not UNIQUE? Change DataType
  26. 26. 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 } ] [ ; ]
  27. 27. 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
  28. 28. HOW DO YOU FIX IT IF IT’S ALREADY GONE OFF? RESTART GAPS Not UNIQUE? Change DataType
  29. 29. 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/
  30. 30. GUIDS 16 bytes Universally unique Many per table 3F2504E0-4F89-41D3-9A0C-0305E82C3301
  31. 31. MORE TERMS Numeric Integer BIG Integer Small number
  32. 32. MORE TERMS Clustered Key Partitioning Key
  33. 33. MORE TERMS Index Constraint Application code Referential Integrity
  34. 34. HOW EASY IS THIS? “Just allocate a surrogate key for every table” Job done. And why do we need data modelers/designers?
  35. 35. WHAT YOU SHOULD DO: Read Up Ensure you use correct terms Understand how your tools create and generate keys Learn about the Outliers Set the standard for correct term use
  36. 36. THANK YOU, YOU WERE GREAT. KAREN LOPEZ @DATACHICK

×