当前位置:网站首页>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
边栏推荐
- 如何快速关闭8080端口
- 中金财富安全吗? 开户需要多久
- solidity 合约地址转钱包、钱包地址转合约
- solidity日期工具
- Jump jump games auxiliary (manual version) py code implementation
- Elastic high-performance computing on the cloud supports the rapid development of the life science industry, reducing costs and increasing efficiency
- Network security detection and prevention test questions (4)
- Solidity contract address to wallet, wallet address to contract
- SEO outsourcing reliable company, enterprise SEO outsourcing company which reliable?
- Solidity get quarterly time
猜你喜欢

Regular expression summary

Trend ea- fixed stop loss and profit per order

一晚上做了一个xpath终结者:xpath-helper-plus

Sorting out the latest data mining competition scheme!

QQ机器人疫情查询/疫情关注等【最新beta2版本】

Google SEO external chain releases 50+ website platform sharing (e6zzseo)

Gbpnzd firm offer for 14 months, simulation for 19 months, test stable

揭秘GES超大规模图计算引擎HyG:图切分

What should I pay attention to in GoogleSEO content station optimization?

Tiger Dao VC products are officially launched, a powerful supplement to seektiger ecology
随机推荐
Huawei released two promotion plans to promote AI talent development and scientific research innovation
158_模型_Power BI 使用 DAX + SVG 打通制作商業圖錶幾乎所有可能
Idea common plug-ins
ECS 7-day practical training camp (Advanced route) -- day04 -- build a portal using ECs and polardb
六、HikariConfig的配置解析
谈谈CNN中的位置和尺度问题
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
QQ机器人官方插件加载配置方法【beta2版本】
Command records of common data types for redis cli operations
Gbpnzd firm offer for 14 months, simulation for 19 months, test stable
MySQL view explanation
Analysis on planting area, output and import of sugarcane in Guangxi in 2021: the output of sugarcane in Guangxi accounts for 68.56% of the total output of sugarcane in China [figure]
What is an operator?
请问通达信开户安全吗?
三、HikariCP获取连接流程源码分析三
云上弹性高性能计算,支持生命科学产业高速发展、降本增效
JVM|运行时数据区(堆空间)
mysql视图讲解
Elastic high-performance computing on the cloud supports the rapid development of the life science industry, reducing costs and increasing efficiency
TCP/IP 测试题(一)