简体   繁体   中英

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 (ie 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM