MySQL Development database naming specification issues

Source: Internet
Author: User
The database name is lowercase.
Table name Prefix _ lowercase.

Then field name:
I see a material like that:
One of the recommended naming conventions is to use lowercase letters and underscores when defining databases, tables, and columns without any uppercase letters.

Do you agree? Is that how it's done?
Although the case does not matter, I just want to see the best specification.

Reply content:

The database name is lowercase.
Table name Prefix _ lowercase.

Then field name:
I see a material like that:
One of the recommended naming conventions is to use lowercase letters and underscores when defining databases, tables, and columns without any uppercase letters.

Do you agree? Is that how it's done?
Although the case does not matter, I just want to see the best specification.

The MySQL case-sensitive policy is this:

  1. 表名And 库名 is to follow the system, that is, Windows does not differentiate, Linux differentiates, MAC depending on the formatting options of the file system can be differentiated or not differentiated, which is not differentiated by default.
  2. 字段名All 不区分 .

All of the SQL statements we see are 大写 in 关键词 vain, and MySQL converts them all to lowercase and then to the incoming query.

This is where to go inside a share ppt
Where to go MySQL development specification. PDF:HTTP://VDISK.WEIBO.COM/S/DR8G_5NKAJGP

Look at the reference, but each has its own norms, relatively a constraint is conducive to collaboration

Approve the use of lowercase and underlined methods.
Table Name method: That's how 【项目名_模块名_表名】 we write.
If you feel too long, you can also remove the project name, the database name is the project name.

My (many years ago colleagues taught, originally also has the suffix info,relation to distinguish the table type, also has the two level topic defaults to base, I feel to look at the table list when the sorting disorder is removed):

The table name consists of the partition module Theme [_ Two-level theme], which recommends a maximum of two-level themes.
The partitions were:
A: application area, store application Data
B: Warehouse area, storing historical data
M: Market area, storing result data
S: buffer, storing buffer data
Recommended field names:
ID primary KEY, CHAR (20)
PID Parent Key, CHAR (20)
xx_id foreign Key, CHAR (x), XX as association table abbreviation
Dflag Delete identity, TINYINT, 0 is normal, 1 is delete, other numbers are used to indicate other states
CTime creation time, datetime, or timestamp
Mtime Modify Time, datetime, or timestamp
Btime start time, datetime, or timestamp
ETime end Time, datetime, or timestamp

I am phper, personal preference for all use lowercase + underline, but the specification used in the company project is the library name and table name using lowercase + underscore, field names using small hump naming, I guess the use of small hump as a field naming specification is the main purpose of the code to be consistent with the variable naming specification.

First find a way to use it, and later feel inappropriate, the next time the design changes on the line. Listen to others, always know that such a good, but do not understand why, boring.
I generally are all named is lowercase, Oracle seems to be more in favor of uppercase, MySQL often you write uppercase, and finally will turn into lowercase, sad, you do not have to capitalize.
Table Name: module prefix _ Table name; History table Name: module prefix _ table name _his;
Field Name: Primary key is called ID; normal field is name, no prefix, if foreign key: foreign key Table name _ foreign key field name in the original table

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.