1、 Basic specifications
Article 1: InnoDB storage engine must be used
Article 2: The utf8 (utf8mb4) character set must be used
Article 3: Chinese notes must be added to data tables and data fields
Article 4: It is forbidden to use stored procedures, views, triggers, and events
Article 5: It is forbidden to store large files or photos
2、 Naming convention
Article 1: Only allowed Use the intranet domain name instead of IP to connect to the database
Article 2: Online environment, development environment test The intranet domain name of the environment database follows the naming specification
Article 3: Database name, table name and field name: lower case, underline style, no more than 32 characters, no mixed use of pinyin and English
Article 4: Table name t_xxx, non unique index name idx_xxx, unique index name uniq_xxx
3、 Table and field design specifications
Article 1: Foreign keys are prohibited. If there are foreign key integrity constraints, application control is required
Article 2: The field must be defined as NOT NULL and the default value must be provided
Article 3: TEXT and BLOB types are prohibited
Article 4: It is prohibited to use decimal to store national currency
Article 5: Varchar (20) must be used to store mobile phone numbers
Article 6: The use of ENUM is prohibited, and TINYINT can be used instead
Article 7: A table must have a primary key, such as auto increment primary key
4、 Index Design Specification
Article 1: It is recommended to limit the single table index to 5
Article 2: The number of single index fields cannot exceed 5
Article 3: It is prohibited to create indexes on attributes that are updated frequently and are not highly differentiated
Article 4: To establish a composite index, the fields with high discrimination must be placed first
5、 SQL Usage Specification
Article 1: SELECT * is prohibited, only necessary fields are obtained, and description column attributes need to be displayed
Article 2: It is prohibited to use INSERT INTO t_xxx VALUES (xxx), and the column attribute of the specified insert must be displayed
Article 3: Implicit attribute conversion is prohibited
Article 4: It is prohibited to use functions or expressions on attributes of WHERE conditions
Article 5: It is prohibited to use JOIN query for large tables and sub query for large tables
Article 6: The OR condition is prohibited and must be changed to IN query
Article 7: Negative queries and fuzzy queries starting with% are prohibited
Article 8: The application must catch SQL exceptions and handle them accordingly