What's the best practice for primary keys in tables?

前端 未结 21 2480
别那么骄傲
别那么骄傲 2020-11-22 14:02

When designing tables, I\'ve developed a habit of having one column that is unique and that I make the primary key. This is achieved in three ways depending on requirements

21条回答
  •  礼貌的吻别
    2020-11-22 14:18

    A natural key, if available, is usually best. So, if datetime/char uniquely identifies the row and both parts are meaningful to the row, that's great.

    If just the datetime is meaningful, and the char is just tacked on to make it unique, then you might as well just go with an identify field.

提交回复
热议问题