Evil
Surrogate  Key Abuse
SSSKASociety to Stop  Surrogate  Key Abuse
Key = a unique predicate which identifies a tuple                            SSSKA
Key   room 204date 2009-04-17                  SSSKA
Surrogate Key = an arbitrary unique ID valueadded to a tuple, unrelated     to tuple contents                          SSSKA
Surrogate Key   ID 44906   room 204date 2009-04-17                  SSSKA
Surrogate Key Abuse =misuse of surrogate keys in a way which harms       your data                       SSSKA
Primary Key =    meaninglessimplementation detail                        SSSKA
SSSKA
SSSKA
SSSKA
SSSKA
SSSKA
SSSKA
Forms of Abuse● No real key● Unnecessary surrogate  keys● Swapping keys                          SSSKA
Forms of Abuse● No real key● Unnecessary surrogate  keys● Swapping keys● ObjectIDs (and UUIDs)                          SS...
Excuses●   "Its standard"●   "There isnt a good key"●   "My framework requires it."●   "Keys shouldnt change"             ...
Excuses● "Its standard"  wrong. SKs not in relational model● "There isnt a good key"  no, you just dont know what it is● "...
Excuses"Performance"                SSSKA
Excuses premature optimization    = doing things for"performance" which you      havent tested                      SSSKA
Excusespremature optimizationgenerally harms actual     performance                         SSSKA
Avoid S.K.A.!● Make sure all relations have real keys● Use natural keys where you can● Avoid premature optimization       ...
If You Really Loved    Your Data, YouWouldnt Abuse Keys.                       SSSKA
SSSKA    Learn More about S.K.A.:http://it.toolbox.com/blogs/database-   soup/primary-keyvil-part-i-7327        (google "p...
Keyvil Lightning Talk
Keyvil Lightning Talk
Upcoming SlideShare
Loading in …5
×

Keyvil Lightning Talk

1,816 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,816
On SlideShare
0
From Embeds
0
Number of Embeds
126
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Keyvil Lightning Talk

  1. 1. Evil
  2. 2. Surrogate Key Abuse
  3. 3. SSSKASociety to Stop Surrogate Key Abuse
  4. 4. Key = a unique predicate which identifies a tuple SSSKA
  5. 5. Key room 204date 2009-04-17 SSSKA
  6. 6. Surrogate Key = an arbitrary unique ID valueadded to a tuple, unrelated to tuple contents SSSKA
  7. 7. Surrogate Key ID 44906 room 204date 2009-04-17 SSSKA
  8. 8. Surrogate Key Abuse =misuse of surrogate keys in a way which harms your data SSSKA
  9. 9. Primary Key = meaninglessimplementation detail SSSKA
  10. 10. SSSKA
  11. 11. SSSKA
  12. 12. SSSKA
  13. 13. SSSKA
  14. 14. SSSKA
  15. 15. SSSKA
  16. 16. Forms of Abuse● No real key● Unnecessary surrogate keys● Swapping keys SSSKA
  17. 17. Forms of Abuse● No real key● Unnecessary surrogate keys● Swapping keys● ObjectIDs (and UUIDs) SSSKA
  18. 18. Excuses● "Its standard"● "There isnt a good key"● "My framework requires it."● "Keys shouldnt change" SSSKA
  19. 19. Excuses● "Its standard" wrong. SKs not in relational model● "There isnt a good key" no, you just dont know what it is● "My framework requires it." get a better framework● "Keys shouldnt change" whats CASCADE for then? SSSKA
  20. 20. Excuses"Performance" SSSKA
  21. 21. Excuses premature optimization = doing things for"performance" which you havent tested SSSKA
  22. 22. Excusespremature optimizationgenerally harms actual performance SSSKA
  23. 23. Avoid S.K.A.!● Make sure all relations have real keys● Use natural keys where you can● Avoid premature optimization SSSKA
  24. 24. If You Really Loved Your Data, YouWouldnt Abuse Keys. SSSKA
  25. 25. SSSKA Learn More about S.K.A.:http://it.toolbox.com/blogs/database- soup/primary-keyvil-part-i-7327 (google "primary keyvil") This talk is copyright 2009 Josh Berkus, and is licensed under the creative commons attribution license

×