当前位置:网站首页>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
边栏推荐
- 网络安全检测与防范 测试题(二)
- electron 基础项目搭建 &&主线程和渲染线程的通信
- JS get data
- SEO outsourcing reliable company, enterprise SEO outsourcing company which reliable?
- Tcp/ip test questions (II)
- 广州华锐互动VR全景为各行各业带来发展
- Development status of China's hydrotalcite industry in 2020 and analysis of major enterprises: the market scale is rapidly increasing, and there is a large space for domestic substitution [figure]
- What is an operator?
- MySQL transaction explanation
- Kotlin Compose 终结toDo项目 点击可以编辑修改todo
猜你喜欢

广州华锐互动打造VR展厅全景在线虚拟展厅

ECS 7-day practical training camp (Advanced route) -- day01 -- setting up FTP service based on ECS
![[today in history] June 25: the father of notebook was born; Windows 98 release; First commercial use of generic product code](/img/ef/a26127284fe57ac049a4313d89cf97.png)
[today in history] June 25: the father of notebook was born; Windows 98 release; First commercial use of generic product code

What is an operator?

158_ Model_ Power Bi uses DAX + SVG to open up almost all possibilities for making business charts

ECS 7-day practical training camp (Advanced route) -- day04 -- build a portal using ECs and polardb
![[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)]

Divine reversion EA
![QQ robot epidemic situation query / epidemic situation concern [latest beta2 version]](/img/25/298dc7b79dddd05914d5f3ba070555.png)
QQ robot epidemic situation query / epidemic situation concern [latest beta2 version]

【历史上的今天】6 月 25 日:笔记本之父诞生;Windows 98 发布;通用产品代码首次商用
随机推荐
Uncover ges super large scale graph computing engine hyg: Graph Segmentation
【C语言练习——打印上三角及其变形(带空格版)】
Record Baidu search optimization thinking analysis
What should I pay attention to in GoogleSEO content station optimization?
TCP/IP 测试题(三)
Google SEO external chain releases 50+ website platform sharing (e6zzseo)
Solidity date tool
网络安全检测与防范 测试题(五)
QQ robot flash forwarding / recall message forwarding [latest beta2 version]
ECS 7-day practical training camp (Advanced route) -- day04 -- build a portal using ECs and polardb
On location and scale in CNN
mysql my. Understanding CNF depends on configuration
如何快速关闭8080端口
Is it safe for tongdaxin to open an account?
Is CICC wealth safe? How long does it take to open an account
想知道新股民怎样炒股票开户?在线开户安全么?
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]
In 2021, China's private equity market is growing, and the scale of private equity fund management reaches 19.78 trillion yuan [figure]
华为发布两大昇腾计划 推动AI人才发展和科研创新
Development status of China's hydrotalcite industry in 2020 and analysis of major enterprises: the market scale is rapidly increasing, and there is a large space for domestic substitution [figure]