开发者

MySQL column name standards / conventions [closed]

开发者 https://www.devze.com 2023-02-16 23:47 出处:网络
Closed. This question is opinion-based. It is not currently accepting answers. 开发者_StackOverflow中文版
Closed. This question is opinion-based. It is not currently accepting answers. 开发者_StackOverflow中文版

Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.

Closed 7 years ago.

Improve this question

I'm looking for document (suggestions) with column name standards or conventions for MySQL. Can anybody suggest any?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号