Presentation on theme: "DAMA - MN 11/20/2002 Designing Your Primary Keys Denise Dykstra DAMA - Minnesota November 20, 2002."— Presentation transcript:
DAMA - MN 11/20/2002 Designing Your Primary Keys Denise Dykstra DAMA - Minnesota November 20, 2002
DAMA - MN 11/20/2002 Isn’t It Inherently Obvious? n Deliberate design n A variety of options n Pros and Cons
DAMA - MN 11/20/2002 Primary Key Rules n Uniquely Identify an object n Ability to Access one object n Link to another table (FK) n No Changes (updates) n Control over Value
DAMA - MN 11/20/2002 Considerations n Prevailing Practice at company n Conceptual vs. Surrogate n Control over value u Business supplies u Database control u Programmatic control u Insert method n Discrete vs. Non-discrete n Scope of uniqueness
DAMA - MN 11/20/2002 Options n Conceptual 3NF n Single column PK for every table u Surrogate u Generated n Homemade sequence or random number n Intelligent key n Record locator (OID) n High / Low value
DAMA - MN 11/20/2002 Surrogate Key Issues n Will it ever have “meaning”? n How is the value determined? n Partitioning ability? n Updates to data: good or bad? n Meaningless to users n Complicates the index strategy n RI could contain both meaningless key and candidate key
DAMA - MN 11/20/2002 Consider this…. A primary key strategy using all meaningless (surrogate, generated) keys can lead to PERFECT referential database integrity, while the data itself is meaningless.
DAMA - MN 11/20/2002 Using Tools n Logical models should directly support business rules n Physical models reflect the database design decisions n Problem is traceability
DAMA - MN 11/20/2002 Database Platforms n Oracle n IBM and DB2 flavors n Sybase n SQL Server n Others?
DAMA - MN 11/20/2002 It Depends! n Understanding various methods helps improve your product, whether it is a data model or a database design. n Use knowledge to achieve project objectives: speed, accuracy, abstraction