Some programs compare database primary key selection

Database, each record needs to have a unique identifier, in general, there are two types of selections:

  • Business use a primary key field
    in many cases it is difficult to find a business field that uniquely identifies
    the business field length may change

  • Automatically generated unique ID as the primary key
    • Uniqueness, generates will not change, you can freely quote
    • Single table in one database scenario:
      • Self-energizing field as ID
    • Under the sub-sub-table repository scenario:
      - UUID
      generally used to generate the Request ID tag single request
      ID generated is preferably monotonic incremental, that is orderly, and the UUID do not have this feature, it is possible to be sorted ID field
      ID has sequence data write performance will improve (B + tree index storage, does not need to seek writing order)
      does not have the business meaning, the UUID meaningless
      32 hexadecimal digits, space consuming
      - Fa build service ID is generated

Guess you like

Origin www.cnblogs.com/yeni/p/11652868.html