Sql naming best practice

前端 未结 12 3036
春和景丽
春和景丽 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:16

    prefixes like that are pointless, unless you have something a little more arbitrary; like two addresses. Then you might use address_1, address_2, address_home, etc

    Same with phone numbers.

    But for something as static as age, gender, username, etc; I would just leave them like that.

    Just to show you If you WERE to prefix all of those fields, your queries might look like this

    SELECT users.user_id FROM users WHERE users.user_name = "Jim"
    

    When it could easily be

    SELECT id FROM users WHERE username = "Jim"
    

提交回复
热议问题