当前位置:网站首页>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
边栏推荐
- MySQL index details
- 35 year old programmer fired Luna millions of assets and returned to zero in three days. Netizen: it's the same as gambling
- PHP design function getmaxstr to find the longest symmetric string in a string - [original]
- Report on the "fourteenth five year plan" and future development direction of global and Chinese indoor vertical farms from 2022 to 2028
- Implementation of seven classes of BlockingQueue interface
- asp. Net web page, ASP connects to the database, and uses asp:panel and asp:dropdownlist controls
- Simple personal summary of tp6 multi application deployment -- Part I [original]
- Thinkphp6 implements a simple lottery system
- A troubleshooting of website crash due to high CPU
- Install cenos in the virtual machine
猜你喜欢
Resolve PHP is not an internal or external command
企业的产品服务怎么进行口碑营销?口碑营销可以找人代做吗?
There is no response to redirection and jump in the laravel constructor [original]
Install SVN in Pagoda and build SVN version Library
Mutex of thread synchronization (mutex)
NPM installation tutorial
The open software of win10 system is too small. How to make it larger (effective through personal test)
[geek challenge 2019] rce me
Wechat applet is bound to a dynamic array to implement a custom radio box (after clicking the button, disable the button and enable other buttons)
[Qunhui] Internet access + custom port
随机推荐
An unexpected attempt (Imperial CMS list template filters spaces and newlines in smalltext introduction)
PHP small factory moves bricks for three years - interview series - my programming life
2020-12-18
企业的产品服务怎么进行口碑营销?口碑营销可以找人代做吗?
CDN with OSS acceleration
Guide de la pompe de données Oracle
Upload script file (one sentence back door) WAF bypass (PHP)
Threejs专用天空盒素材,五种天空盒素材免费下载
Install cenos in the virtual machine
Laravel framework Alipay payment fails to receive asynchronous callback request [original]
线程同步之互斥量(互斥锁)
College C language final exam · multiple choice questions · summary notes of mistakes and difficulties
六、项目实战---识别猫和狗
Ubuntu installs PostgreSQL and uses omnidb to view
Modify the number of Oracle connections
[Qunhui] import certificate
A troubleshooting of website crash due to high CPU
Zhimeng CMS will file a lawsuit against infringing websites
Minecraft 1.16.5 biochemical 8 module 1.9 version 1.18 version synchronization
Knowledge of functions