当前位置:网站首页>Physical design of database design (2)
Physical design of database design (2)
2022-06-26 04:28:00 【good writings make people copy them】
What does physical design do
One . Choose the right database management system
Oracle、SqlServer、MySql And PgSQL
- Copyright 、 Cost considerations :

- Functional considerations :
Oracle: A good one in the industry DBMS, A high performance , It is suitable for large transaction operations .
- Operating system considerations :
SqlServerL Only support Windows Under the system
Oracle、MySql And PgSQL: Can support linux System 、windows System
- Development language considerations :
If you use .net development language , Use SQLServer better
- Application scenario considerations :
mysql And PgSQL Applicable to Internet projects
Oracle、SqlServer Applicable to enterprise level projects (Oracle, E.g. carrier level 、 financial , Because it has good scalability , High safety ,SqlServer: Small and medium-sized enterprises erp)
Introduce Mysql Common storage engines

Two 、 Define database 、 Naming conventions for tables and fields
All object naming principles :
1. Readability principle
Be careful : Case naming ( hump ), yes , we have DBMS Sensitive to case , such as Mysql
2. The principle of expressiveness
The name of the object should be able to describe the object it identifies .
for example : Table name , It can reflect the stored data content
For stored procedures , The stored procedure name should reflect the function of the stored procedure
3. Long name principle
Use as few or no abbreviations as possible .
For databases DB Any object other than the name

Such a name , When only looking at the name of the watch 、 Field name , I have no idea what the watch is for . During development and post operation and maintenance , Poor readability , Need to rely entirely on manuals .
3、 ... and . According to the selected DBMS The system selects the appropriate field type
Selection of data type of column :1. It will affect the cost of data storage space ,2. Affect the performance of data query
The principle of field type selection :
When a column can select multiple data types , Should be Number type is preferred , Next is the date or binary type , Finally, the character type .
For the same level of data type , Should be Give priority to data types that take up less space .

Mysql stay MySQL For internal use 4 Bytes INT Type to store timestamp data , Timestamp type , It can only be stored in 2038 year , Because now 2020 Years. , Use it with caution . Empathy ,int Type to store time should also be used with caution !
The above principles are mainly considered from the following two perspectives :
1. When comparing data ( Query criteria 、join Conditions and order ) When waiting for operation : The same data , Character processing is often slower than number processing
2. In the database , Data processing is in pages , The smaller the length of the column , Good for performance .
How to select field type in database :
- char And varchar How to choose ?
1. If the length of data to be stored in the column is almost the same , Consider using char; Otherwise, we should consider using varchar . Such as : ID number , cell-phone number
2. If the maximum data length in the column is less than 50Byte, Generally, we also consider char( If the column is rarely used , Based on saving space and reducing I/O The consideration of , Or choose to use varchar)
3. In general, it is not appropriate to define more than 50Byte Of char Type column .( almost 15 Characters )
- decimal And float How to choose
1.decimal For storing accurate data , Two float Can only be used to store imprecise data .
2. because float The cost of storage space is generally higher than decimal Small , Therefore, imprecise data is preferred float type
- How time types are stored
1. Use int To store the advantages and disadvantages of time fields
advantage : Field length ratio detetime Small
shortcoming : Inconvenient to use , To convert a function
Limit : It can only be stored in 2038-01-19 11:14:07, because 2^32 by 2147483648
2. Time granularity to store
year 、 month 、 Japan 、 Hours 、 branch 、 second 、 Zhou
Four 、 Other considerations for database design :
1. How to choose a primary key

2. Avoid using foreign key constraints
- Reduce the efficiency of data import , The impact of high concurrency environment is very serious
- Increased maintenance costs
- However, foreign key constraints are not recommended , But the associated column must be indexed
3. Avoid using triggers
1. Reduce the efficiency of data import
2. Unexpected data exceptions may occur , Especially when business requirements change
3. Complicate business logic
4. About reserved fields
1. Unable to know exactly the type of reserved field .
2. Unable to accurately know the contents stored in the reserved field
3. The cost of maintaining the reserved fields later , The cost of adding a field is the same
4. strictly prohibit Use reserved fields
5、 ... and . Anti normal design
For the sake of performance and reading efficiency , Appropriately violate the requirements of the third paradigm , and A small amount of data redundancy is allowed . Space for time .




Why anti paradigm
1. Reduce the number of table associations
2. Increase data reading efficiency
3、 The anti paradigm design must be moderate
边栏推荐
- PHP has the problem of using strtotime to obtain time in months and months [original]
- Fastadmin always prompts sqlstate[23000]: integrity constraint violation: 1052 column 'ID' in order clause is am
- Computer network high frequency interview questions
- SQL related knowledge - DDL
- 08_SpingBoot 集成Redis
- Go SQL parsing time Time type
- Analysis report on the development trend and operation status of China's environmental monitoring instrument industry from 2022 to 2028
- [Qunhui] Internet access + custom port
- [QT] dialog box
- SQL related knowledge - DQL
猜你喜欢

Sixtool- source code of multi-functional and all in one generation hanging assistant

mysql高级学习(跟着尚硅谷老师周阳学习)
![[QT] dialog box](/img/ca/e65a0c167a4509f7c6a241870f6a32.png)
[QT] dialog box

Minecraft 1.16.5 生化8 模组 1.9版本 1.18版本同步

Computer network high frequency interview questions

SixTool-多功能多合一代挂助手源码

小程序中实现视频通话及互动直播功能
![PHP design function getmaxstr to find the longest symmetric string in a string - [original]](/img/45/d8dae9e605a2f411683db7a2d40d0b.jpg)
PHP design function getmaxstr to find the longest symmetric string in a string - [original]

Yapi cross domain request plug-in installation

CDN with OSS acceleration
随机推荐
pip 批量完全卸载包
[从零开始学习FPGA编程-45]:视野篇 - 集成电路助力数字化时代高质量发展-2-市场预测
Computer network high frequency interview questions
Nailing open platform - applet development practice (nailing applet client)
Tencent Interviewer: How did binder get its system services?
An unexpected attempt (Imperial CMS list template filters spaces and newlines in smalltext introduction)
Thinkphp6 implements a simple lottery system
Microsoft prohibits Russian users from downloading and installing win10/11
Video label forbids downloading. The test is valid. Hide button. The test is valid at three points
Zeromq from getting started to mastering
Nailing open platform - applet development practice (nailing applet server side)
2021-02-07
PHP inherited in class return does not work
mysql自帶的性能測試工具mysqlslap執行壓力測試
ctf [RoarCTF 2019]easy_ calc
Understand CGI and fastcgi
Read / write lock for thread synchronization
Minecraft 1.16.5 生化8 模组 1.9版本 1.18版本同步
PHP small factory moves bricks for three years - interview series - my programming life
Your requirements could not be resolved