database - Should the contents of a column acting as a primary key be interpretable or purely unique integers -


i have luxury of designing database scratch. when designing columns act unique keys should use unique integers or should attempt make values interpretable. if had lookup table of ward names in hospital should id column contain unique codes in someway relate name of ward or unique integers?

resist temptation overload id values meaning. use other attributes store info you're considering stuffing id.

overloading id "meaning" bad because:

  • if data being stuffed id changes, must id. id's should never change
  • if data type of data changes, you'll have problem, example:
    • if id numeric, , stuffed info changes numeric text, you'll have big problems
    • if stuffed data changes simple field one-to-many child, model break
  • what believe has "important" meaning may not important in future. "specially encoded" data become useless , burden, serious restriction
  • what "identifies" product may change business evolves

if have seen idea attempted many times, never successfully. in every case, idea scraped , surrogate ids introduced replace magic ids, risk , development cost associated task.

in career, have seen of problems listed above happen.


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

mapreduce - Resource manager does not transit to active state from standby -

serialization - Convert Any type in scala to Array[Byte] and back -