Sql naming best practice

前端 未结 12 2723
春和景丽
春和景丽 2021-02-14 09:48

I\'m not entirely sure if there\'s a standard in the industry or otherwise, so I\'m asking here.

I\'m naming a Users table, and I\'m not entire

12条回答
  •  隐瞒了意图╮
    2021-02-14 10:34

    I explicitly named my columns using a prefix that was related to the table

    i.e. table = USERS, column name = user_id, user_name, user_address_street, etc.
    

    before that, when i started using JOINS I had to alias the crap out of the column names to avoid conflict in the query results, and then when accessed from templates in a MVC View, if the query result field name didn't match the published db schema, the template designers would get all confused and have to ask for the SQL VIEW to determine the correct field name to use.

    So it looks messy to use a prefix in a column name, but in practice it works better for us.

提交回复
热议问题