Use item specific prefixes and autonumber for primary keys?

后端 未结 9 1473
孤街浪徒
孤街浪徒 2020-12-05 20:12

We had a meeting this morning about how would should store our ID for some assets that we have in our database that we are making, the descusion generated a bit of heat so I

9条回答
  •  不知归路
    2020-12-05 20:38

    The one and only advantage of example 2 is that you can easily tell just from the primary key alone which row of which table this key applies to. The idea is nice, but whether or not it is useful depends on your logging and errormessage strategies. It does probably have a performance disadvantage, so I would not use it unless you can name some specific reasons why to use it.

    (You can have this advantage also by using a global sequence to generate numerical keys, or by using different numeric ranges, last digits or whatever. Then you don't have performance disadvantages, but maybe you won't find the table so easily.)

提交回复
热议问题