MySQL naming conventions, should field name include the table name?

前端 未结 9 2319
梦谈多话
梦谈多话 2021-02-07 08:59

A friend told me that I should include the table name in the field name of the same table, and I\'m wondering why? And should it be like this? Example:

(Table)         


        
9条回答
  •  -上瘾入骨i
    2021-02-07 09:32

    Personally I don't add table names for field names in the main table but when using it as a foreign field in another table, I will prefix it with the name of the source table. e.g. The id field on the users table will be called id, but on the comments table it, where comments are linked to the user who posted them, it will be user_id.

    This I picked up from CakePHP's naming scheme and I think it's pretty neat.

提交回复
热议问题