Picking the best primary key + numbering system

前端 未结 13 1647
盖世英雄少女心
盖世英雄少女心 2020-12-02 14:50

We are trying to come up with a numbering system for the asset system that we are creating, there has been a few heated discussions on this topic in the office so I decided

13条回答
  •  心在旅途
    2020-12-02 15:21

    As mentioned before, keep your internal primary keys as just keys, whatever the most optimal datatype is on your platform.

    However you do need to let the numbering system argument be fought out, as this is actually a business requirement, and perhaps let's call it an identification system for the asset.

    If there is only going to be one identifier, then add it as a column to the main table. If there are likely to be many identification systems (and assets usually have many), you'll need two more tables

        Identifier-type table             Identifier-cross-ref table
          type-id             ------------> type-id              (unique
          type-name                         identifier-string     key)
                                            internal-id
    
    
    

    That way different people who need to access the asset can identify in their own way. For example the server team will identify a server differently from the network team and different again from project management, accounts, etc.

    Plus, you get to go to all the meetings where everyone argues with each other.

提交回复
热议问题