MySQL column name standards / conventions [closed]

六眼飞鱼酱① 提交于 2019-12-02 20:28:36

There's nothing "standard" in this space I'm aware of, unlike say Sun's old Java conventions. Anything you adopt will be personal/company preference.

That said, I do like prefix conventions:

  • t_ for table
  • v_ for view
  • idx_ for index
  • tx_ for text field
  • dt_ for date field
  • n_ for numeric field
  • id_ for identify field
  • nm_ for something that's specifically a name
  • is_ for booleans, whether 0/1, yes/no or otherwise
  • fk_ as an optional foreign key identifer; you may prefer to stick with id_ though, to keep the field the same as its primary key counterpart, e.g. id_customer -> id_customer, rather than an fk_customer

Naming conventions comes into play when using frameworks like Ruby on Rails or Zend that subscribe to convention over configuration. Anything that will scaffold forms for you or "auto discover" your database. Looking at these conventions could also help you decide on a naming strategy even if you are not using a framework.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!