Is ID column required in SQL?

前端 未结 8 1562
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-29 23:50

Traditionally I have always used an ID column in SQL (mostly mysql and postgresql).

However I am wondering if it is really necessary if the rest of the columns in ea

8条回答
  •  既然无缘
    2020-12-30 00:00

    Using IDs to key tables means you can change the content as needed without having to repoint things

    Ex. if every row points to a unique user, what would happen if he/she changed his name to let say John Blblblbe which had already been in db? And then again, what would happen if you software wants to pick up John Blblblbe's details, whose details would be picked up? the old John's or the one ho has changed his name? Well if answer for bot questions is 'nothing special gonna happen' then, yep, you don't really need "ID" column :]

    Important:

    Also, having a numeric ID column with numbers is much more faster when you're looking for an exact row even when the table hasn't got any indexing keys or have more than one unique

提交回复
热议问题