MySQL non primary foreign key

前端 未结 3 1696
误落风尘
误落风尘 2020-12-17 04:05

I\'m a bit of a newbie and I can\'t get my head around primary keys as foreign keys. To me, foreign keys are meant to connect two rows of a table together. Therefore, it wou

3条回答
  •  臣服心动
    2020-12-17 04:11

    The reason that you use a "meaningless" value for a primary key, is that "meaningful" values have a tendency to change from time to time.

    In the case of a user being renamed, then you don't want to have to go and change many rows in other tables. This is why it's normal practice to give them a meaningless ID (typically auto-incrementing).

提交回复
热议问题