Database “key/ID” design ideas, Surrogate Key, Primary Key, etc

前端 未结 7 1865
北荒
北荒 2021-02-09 16:15

So I\'ve seen several mentions of a surrogate key lately, and I\'m not really sure what it is and how it differs from a primary key.

I always assumed that ID was my prim

7条回答
  •  情书的邮戳
    2021-02-09 16:35

    Users Table

    Using a Guid as a primary key for your Users table is perfect.

    LogEntry table

    Unless you plan to expose your LogEntry data to an external system or merge it with another database, I would simply use an incrementing int rather than a Guid as the primary key. It's easier to work with and will use slightly less space, which could be significant in a huge log stretching several years.

提交回复
热议问题