开发者

naming conventions of Field Name

What is your naming conventions of Field Name..

Which is popular way?

开发者_如何学运维

Example:

firstname
First_Name
first_name
firstName
FirstName



category_id
categoryID
CategoryID
categoryId


I would recommend first_name and category_id due to readability and easily understandable.


This is all a matter of preference. I personally am more used to camelcase (FirstName) or for id fields (CategoryID) to break away from it. But that is just because all of the databases I have been in lately are set up using it. So it is more whatever feels natural to you.

As for ids and foreign keys, I make the id in both tables the same (i.e. Category table would have CategoryID as the key and anything referencing it would also have CategoryID for the field name).


Usually, it should be all lowercase chars and using _ between letters.

But for example if you have a table Category and a primary key, in my opinion this should by id (not category_id). I use category_id in another table as a foreign key.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜