Is prefixing each field name in a table with abbreviated table name a good practice?

后端 未结 14 1963
-上瘾入骨i
-上瘾入骨i 2020-12-16 19:26

Do you prefix each field in a table with abbreviated table name?

Example:

Table: User

Fields:
user_id
user_name
user_password

Or d

14条回答
  •  醉梦人生
    2020-12-16 20:07

    I wouldn't do it. If you want the information which table a field belongs to, you can always write your queries as

    select user.id, user.name from user where ...
    

    But imagine you decide for whatever reason to rename one of your tables (maybe from 'user' to 'customer'). You would have to rename all fields as well, to remain consistent.

    My opinion: There is no good reason why you should do it, and several good reasons not to do it.

提交回复
热议问题