Keyvil Lightning Talk

27
Evil

description

 

Transcript of Keyvil Lightning Talk

Page 1: Keyvil Lightning Talk

Evil

Page 2: Keyvil Lightning Talk
Page 3: Keyvil Lightning Talk
Page 4: Keyvil Lightning Talk

SurrogateKey

Abuse

Page 5: Keyvil Lightning Talk

Society to StopSurrogateKey Abuse

SSSKA

Page 6: Keyvil Lightning Talk

Key = a unique predicatewhich identifies a tuple

SSSKA

Page 7: Keyvil Lightning Talk

Keyroom 204

date 2009-04-17

SSSKA

Page 8: Keyvil Lightning Talk

Surrogate Key = an arbitrary unique ID value

added to a tuple, unrelated to tuple contents

SSSKA

Page 9: Keyvil Lightning Talk

Surrogate KeyID 44906room 204

date 2009-04-17

SSSKA

Page 10: Keyvil Lightning Talk

Surrogate Key Abuse =misuse of surrogate keys

in a way which harmsyour data

SSSKA

Page 11: Keyvil Lightning Talk

Primary Key =meaningless

implementation detail

SSSKA

Page 12: Keyvil Lightning Talk

SSSKA

Page 13: Keyvil Lightning Talk

SSSKA

Page 14: Keyvil Lightning Talk

SSSKA

Page 15: Keyvil Lightning Talk

SSSKA

Page 16: Keyvil Lightning Talk

SSSKA

Page 17: Keyvil Lightning Talk

SSSKA

Page 18: Keyvil Lightning Talk

SSSKA

Forms of Abuse●No real key●Unnecessary surrogate keys

●Swapping keys

Page 19: Keyvil Lightning Talk

SSSKA

Forms of Abuse●No real key●Unnecessary surrogate keys

●Swapping keys●ObjectIDs (and UUIDs)

Page 20: Keyvil Lightning Talk

SSSKA

Excuses● "It's standard"

● "There isn't a good key"

● "My framework requires it."

● "Keys shouldn't change"

Page 21: Keyvil Lightning Talk

SSSKA

Excuses● "It's standard"

wrong. SKs not in relational model● "There isn't a good key"

no, you just don't know what it is● "My framework requires it."

get a better framework● "Keys shouldn't change"

what's CASCADE for then?

Page 22: Keyvil Lightning Talk

SSSKA

Excuses

"Performance"

Page 23: Keyvil Lightning Talk

SSSKA

Excusespremature optimization

= doing things for "performance" which you

haven't tested

Page 24: Keyvil Lightning Talk

SSSKA

Excusespremature optimizationgenerally harms actual

performance

Page 25: Keyvil Lightning Talk

SSSKA

Avoid S.K.A.!● Make sure all relations have real keys● Use natural keys where you can● Avoid premature optimization

Page 26: Keyvil Lightning Talk

SSSKA

If You Really LovedYour Data, You

Wouldn't Abuse Keys.

Page 27: Keyvil Lightning Talk

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

SSSKA