MySQL Design specification

Source: Internet
Author: User
Tags memory usage

First, the basic norms

    1. You must use the InnoDB storage engine
    2. You must use the UTF8 character set
    3. Data table, data fields must be added in Chinese comments

Second, the design code
    1. The library name, table name, field name must be lowercase, preferably not camel, using "_" to differentiate, such as user_name
    2. Library name, table name, field name should not be too long, control within 12 character range
    3. Each table is set to a self-increment primary key, and the primary key should not be modified. (Avoid page splitting, reduce table fragmentation to improve space and memory usage)
    4. can use int type to replace varchar, char with int type as far as possible
    5. No more than 20 fields in a single table field
    6. Define a not NULL for each field and provide a default value
    7. Use varchar (20) to save the phone number, as it may involve an area code or a country code that may appear + + ()
III. SQL specification
    1. SQL as simple as possible
    2. Avoid using SELECT *
    3. or overwrite as in or union
    4. Avoid%xxx rewriting to xxx%
    5. INSERT into A values (AA,VV,CC), to indicate which columns are inserted, to avoid creating an accident due to inconsistent sequence
    6. Prohibit the use of functions on the where field, to be used after a condition. SELECT uid from T_user WHERE day>= unix_timestamp (' 2017-02-15 00:00:00 ')

MySQL Design specification

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: 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.