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

后端 未结 14 1966
-上瘾入骨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:22

    If you are using a UNIQUE PREFIX for each table, then

    • No need to use an alias for joins (except self join)
    • All the columns in the database should be unique in name
    • You can easily identity the table from column name itself(from a output or select query)
    0 讨论(0)
  • 2020-12-16 20:23

    Don't do that. It's redundant and leads to frustration in the long run.

    The only field, where you could apply this might be id, because user_id would obviously be the id of the user and it would simplify writing joins in SQL. But I wouldn't even do that.

    0 讨论(0)
提交回复
热议问题