mysql - 为什么不用驼峰命名创建表名和字段?
PHP中文网
PHP中文网 2017-04-17 13:48:46
0
5
1353
PHP中文网
PHP中文网

认证0级讲师

reply all(5)
Ty80

Whatever, name it whatever you like

http://stackoverflow.com/questions/7899200/is-there-a-naming-convention-for-mysql

迷茫

Actually, this is a norm, not a rule. So you can use camel case to name it, but we should avoid using camel case to name it.
Not just databases, but also ordinary programs, because:

MYSQL 5.7 FEATURES. THIS MANUAL DESCRIBES FEATURES THAT ARE NOT INCLUDED IN EVERY EDITION OF MYSQL 5.7; IN YOUR EDITION OF MYSQL 5.7, REFER TO YOUR MYSQL 5.7 LICENSE AGREEMENT OR CONTACT YOUR ORACLE SALES REPRESENTATIVE.

Can you read this text at a glance?

MySQL 5.7 features. This manual describes features that are not included in every edition of MySQL 5.7; such features may not be included in the edition of MySQL 5.7 licensed to you. If you have any questions about the features included in your edition of MySQL 5.7, refer to your MySQL 5.7 license agreement or contact your Oracle sales representative.

People are used to seeing a certain standard. When they see a hump, they have to use their brains to analyze it, okay? Not only do you need to understand it, but the people maintaining it behind the scenes also need to understand it.

PHPzhong

The advantage of camel case naming is good readability. If the variable names in the code are all uppercase or lowercase, or have underscores, the readability of the code will be poor, and the variables in all uppercase letters will conflict with the final variables.

Imagine the scenario where the variables in the program are all capitalized...

驼峰法: myCatName();
下划线: my_cat_name();
全小写: mycatname();
全大写: MYCATNAME();

In fact, the camel case method should be the closest to the specification of written language, and there is nothing wrong with reading such code.

Personally, I feel that whether it is the camel case naming method or the all-capitalization of final type, it is completely a programming habit. Because of its many advantages, it has gradually evolved into a standard.
There are not as many database-related codes as there are in other programming languages. Writing SQL in all uppercase (lowercase) letters will not affect readability, and all-capital table names and field names will not dazzle people.
And when writing SQL, if the field names are named in camel case, the DBA will probably hate the case switching.

左手右手慢动作

Old-school developers all use lowercase and underscore. Many of them may have been transferred from Oracle. In fact, it is better to use camel case. The most important thing is that it is reflected in the convenience of development and mapping with the persistence layer framework. More aspects, such as: mybatis, anyone who has written mapper. Modification is troublesome though. It’s much easier to copy the name directly

伊谢尔伦

I have been working on database development for almost six years. It can be said that I have been writing SQL for six years. The person in charge will tell you. If you write sql, you must abide by the underscore specification. A little bit data sensitive. It’s all used like this. This is also the norm. As for the camelback, you can use it if you develop java code or other code. It is not suitable for writing sql. The advantage is high readability and strong distinction. For example, use the table name temp_a. Then I know this is temporary table a. Of course you can say I'm TempA. So complicated. Here are the Taobao temporary tables of temp_taobao_20170101 and 20170101. TempTaoBao20170101. Is it a bit long? Then I'll make it a little more complicated. Temp_tabao_cust_info Taobao customer information temporary table. It can even be abbreviated. temp_TB_cust_info, what if it is hump. tempTBCustInfo. Database table names and fields generally have business meanings. Everyone knows that it is difficult to write a sentence without any punctuation marks. That is why underlining is used. I was missing a period in the previous sentence. Do you see how hard it is?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!