Detailed Database specification

Source: Internet
Author: User
Tags lowercase

The database name, table name, field name naming specification:

1. Hump notation: Refer to the specification of named variable names in Java, that is, if there is only one word, all lowercase, and when multiple words, the first word is all lowercase, and all subsequent words are capitalized in the first letter. To illustrate:

Username,id,userpasswd,creattime,updatetime,age and so on.

2, underline notation: is a number of words separated by underscores, all the words lowercase, 32 characters, without preserving the keywords, all fields are NOT null. To illustrate:

User_name,id,user_passwd,create_time,update_time,age and so on.

Combining the above two naming conventions, the personal feeling hump method is better. The feeling looks beautiful, the readability is strong, occupies the space to be small, the typing is more convenient, to the person who has used the Java, has the better. C + + and Python are underscores, Java and go are humps. In fact, as long as the Java or Go program people, basic will feel more beautiful hump. The underline is really hard to beat. But the underscore is already a DBA's norm, and it's hard to change.

3, the field specification.

1) Non-negative value: unsigned

2) Storage Ipv4:int unsigned

3) store floating-point values: decimal, do not use float and double

4) Reasonable selection of integral type range: tinyint, smallint, mediumint, int, bigint

5) All fields are: notnull decorated, and default values are set

6) Reasonable selection of time types: year, date, datetime, timestamp

7) varchar (n) as small as possible: N represents the number of characters, not the number of bytes

8) Whenever possible: text, blob, enum (replace with tinyint)

4, library table specification.

1) prohibit partition table;

2) Reasonable sub-database sub-table;

3) Separation of hot and cold data;

4) Recommended hash list, table name suffix to make 10 decimal number, the number must start from 0. The time-to-date table should conform to the YYYY[MM][DD][HH] format, for example 2013071601. The year must be represented by a 4-digit number. For example, according to the daily scattered table user_20110209, monthly scattered table user_201102;

5) All tables need to be annotated;

6) prohibit the storage of large volume, Big Data (5000W)

Second, the global specification. Default storage engine, default character set

Third, the primary key specification. Each table must have a primary key, and it is recommended to use the self-unsigned integer data.

Iv. Index specification.

V. Specification of SQL statements.

Second, the primary key specification.

Detailed Database specification

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.