当前位置:网站首页>Mysql database design suggestions
Mysql database design suggestions
2022-06-25 19:09:00 【Daiyuanpei】
【 mandatory 】 The name of the database must be controlled in 32 Within characters , It consists of English characters and numbers . It is forbidden to use Chinese .
【 mandatory 】 The character set must be explicitly specified when creating the database , And the character set can only be utf8 perhaps gbk.
【 mandatory 】 The table name must be controlled within 32 Within characters . System reserved words and special characters cannot be used , Only letters can be used 、 Numbers and underscores .
【 mandatory 】 Column names must be controlled within 32 Within characters . System reserved words and special characters cannot be used , Only letters can be used 、 Numbers and underscores .
【 mandatory 】 The character set must be explicitly specified when creating a table , And the character set must be the same as the database character set ,utf8 perhaps gbk.
【 mandatory 】 The table storage engine type must be explicitly specified when creating a table , By default InnoDB. If necessary MyISAM And other engines , The unified platform cannot support .
【 mandatory 】InnoDB The table must have a primary key , The primary key must be self incrementing (auto_increment attribute )BIGINT type . The primary key column cannot be updated .
【 mandatory 】 All fields in the table must be NOT NULL attribute , Business can be defined as needed DEFAULT value .
【 mandatory 】 Fields and tables must have COMMENT.
【 mandatory 】 Field names in the table cannot use keywords
【 mandatory 】BLOB/TEXT Do not have default values
【 mandatory 】 Partitioned tables are not allowed .
【 mandatory 】 No use SELECT * Take all fields
【 mandatory 】INSERT You need to specify the field name to be inserted
【 mandatory 】 Triggers are not supported (Triger)
【 mandatory 】 Stored procedures are not supported (Procedure)
【 mandatory 】 Foreign key not supported (Foreign Key)
【 mandatory 】 Function not supported (Function)
【 mandatory 】 Views are not supported (Views)
【 mandatory 】 Events are not supported (Event)
【 mandatory 】DML Statement and DDL Separate the bill of lading
【 mandatory 】DML SQL The online order must be modified every time 1500 Row data select sleep(1)
【 mandatory 】drop The statement must have IF EXISTS, And one drop Statement can delete only one table
【 Strongly recommended 】 Table self increasing critical value inspection
【 Strongly recommended 】 Table name | Field names can only be lowercase
【 Strongly recommended 】 It is not recommended to use ENUM and SET.
【 Strongly recommended 】VARCHAR And CHAR The choice of : With UTF8 or GBK For example ,VARCHAR(200) contrast CHAR(200), On storage InnoDB Has been to CHAR(200) Fields are treated as variable length fields , There is no difference between the two . But for example, we store 32 Of length md5 value , You should use CHAR(32), Because although in InnoDB The storage layer is similar to VARCHAR(32) There is no difference , But use CHAR(32) It is helpful to convey the information that this is a regular field .
【 Strongly recommended 】BLOB,TEXT,MEDIUMTEXT,LONGTEXT It is not recommended to use .
【 Strongly recommended 】 Large tables with active business must have the creation time field of row data create_time And last update time fields update_time
【 Strongly recommended 】 The only key is “uk_” start , The general index is “idx_” start , All in lowercase , By table name / The name or abbreviation of the field is used as the suffix .
【 Strongly recommended 】InnoDB and MyISAM Storage engine table , Index type must be BTREE.
【 Strongly recommended 】 The length of each index record in a single index cannot exceed 64KB
【 Strongly recommended 】 The number of indexes on a single table cannot exceed 7 individual
【 Strongly recommended 】sql where The condition must have an index
【 Strongly recommended 】JOIN Table does not recommend more than 3 individual
【 Mandatory advice 】 It is strongly not recommended that sql Statement used %S% perhaps %S Fuzzy query
【 Suggest 】 The state of being less selective in a business status、 type type Etc. are recommended tinytint perhaps smallint type
【 Suggest 】 In business IP Unsigned integers are recommended for address fields int(10) UNSIGNED type
【 Suggest 】datetime Recommended int replace
边栏推荐
- 华为发布两大昇腾计划 推动AI人才发展和科研创新
- Analysis on China's aluminum foil output, trade and enterprise leading operation in 2021: dongyangguang aluminum foil output is stable [figure]
- 中金财富安全吗? 开户需要多久
- Uncover ges super large scale graph computing engine hyg: Graph Segmentation
- How to quickly close port 8080
- Kotlin Compose 终结toDo项目 点击可以编辑修改todo
- 【历史上的今天】6 月 25 日:笔记本之父诞生;Windows 98 发布;通用产品代码首次商用
- Analysis of China's medical device industry development environment (PEST) in 2021: the awareness of medical care is enhanced, and the demand for medical device products is also rising [figure]
- Electronic package to generate EXE file
- Network security detection and prevention test questions (II)
猜你喜欢

JVM | runtime data area (heap space)

【C语言练习——打印上三角及其变形(带空格版)】

158_模型_Power BI 使用 DAX + SVG 打通制作商業圖錶幾乎所有可能

PHP synchronizes website content to hundreds of websites to improve SEO ranking
![[C language practice - print the upper triangle and its deformation (with blank version)]](/img/df/f38dc57c6a2de522acd91929ced1ad.png)
[C language practice - print the upper triangle and its deformation (with blank version)]

Analysis on the market scale and pattern of contrast agents in China in 2021: Jiangsu Hengrui pharmaceutical, general electric, Yangzijiang Pharmaceutical Group, Bayer and bleco account for more than

LeetCode-101-对称二叉树

为什么生命科学企业都在陆续上云?
![Analysis of global tea production, consumption and import and export trade: China's tea production ranks first in the world [figure]](/img/16/ab5056dd26cf7b1a761a92eea46e54.jpg)
Analysis of global tea production, consumption and import and export trade: China's tea production ranks first in the world [figure]

最新數據挖掘賽事方案梳理!
随机推荐
Leetcode-78-subset
Server journey from scratch - Yu Zhongxian integrated version (IP access server, LNMP compilation and installation, Lua environment and socket expansion)
Analysis on development scale and development trend of China's night economy industry in 2021 [figure]
158_模型_Power BI 使用 DAX + SVG 打通制作商業圖錶幾乎所有可能
Tcp/ip test questions (4)
Analysis on the market scale and pattern of contrast agents in China in 2021: Jiangsu Hengrui pharmaceutical, general electric, Yangzijiang Pharmaceutical Group, Bayer and bleco account for more than
What are Baidu collection skills? 2022 Baidu article collection skills
五、HikariCP源码分析之初始化分析二
In 2021, China's private equity market is growing, and the scale of private equity fund management reaches 19.78 trillion yuan [figure]
TCP/IP 测试题(二)
Is it safe to open an account with flush?
Analysis on market scale and supply of China's needle coke industry in 2020 [figure]
Connecting PHP to MySQL instances in the lamp environment of alicloud's liunx system
谈谈CNN中的位置和尺度问题
Current situation and trend analysis of China's glass packaging containers in 2021: the revenue of glass packaging containers increases year by year [figure]
User management and permissions
Network security detection and prevention test questions (II)
Paddleocr learning (II) paddleocr detection model training
Analysis on China's aluminum foil output, trade and enterprise leading operation in 2021: dongyangguang aluminum foil output is stable [figure]
Command records of common data types for redis cli operations