Use item specific prefixes and autonumber for primary keys?

后端 未结 9 1455
孤街浪徒
孤街浪徒 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:36

    I personally believe the first approach is far, far better. It lets the database software do simple integer comparisons to find and sort by the key, which will improve table operation performance (SELECTs, complex JOINs, by-key INDEX lookups, etc.)

    Of course, I'm assuming that either way, you're using some kind of auto-incrementing method to produce the IDs - either a sequence, an AUTO_INCREMENT, or something similar. Do me a favor, and don't build those in your program's code, OK?

提交回复
热议问题