database - Would you ever create a relationship on a natural ID or use an internal ID and emulate the natural ID relationship? -


possible duplicate:
surrogate vs. natural/business keys

if given 2 tables, level1 [id, title, number] level2 [id, fkid???, title, number]

a user of system understands level2 related level1 based on level1's number, question is, make relationship based on internal id , "emulate" relationship "number" or use "number" field , done it?

the 2 standard reasons relating on database id rather natural id are:

  1. it's difficult guarantee natural id never change under circumstance
  2. generally natural id takes more space , not efficient index database id (though of course not hard , fast - depends on data constituting natural id). using database id, can avoid duplication of business data.

Comments

Popular posts from this blog

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -