当前位置:网站首页>Database basic notes
Database basic notes
2022-06-28 22:17:00 【Yuyy】
This paper is finally updated at 687 Days ago, , The information may have developed or changed .
It covers
ACID,NULL,MVCC, constraint 、 conceptual model 、 Third normal form 、 Connect
1. ACID
Database management system Business (transaction) Four characteristics of ( Explain in sequence according to the acronym when analyzing ): Atomicity (Atomicity)、 Uniformity (Consistency)、 Isolation, (Isolation)、 persistence (Durability) Transaction , It's a Operation sequence , These operations are either performed , Either not , It is an indivisible unit of work .( A set of instructions or operations that perform a single logical function is called a transaction )
Detailed explanation
1. Atomicity
Atomicity means that a transaction is a An indivisible unit of work , Either the operations in the transaction occur , Or none at all . May adopt “A towards B Transfer accounts ” This example is used to illustrate stay DBMS in , By default One SQL It's a separate business , The business is Automatic submission Of . Only explicit use start transaction Start a transaction , To put a block of code in a transaction .
2. Uniformity
Consistency means in Before and after a transaction , The database integrity constraint is not broken . This means that database transactions cannot be destroyed Integrity of relational data as well as Consistency in business logic . Such as A to B Transfer accounts , Whether the transaction operation of transfer is successful or not , The total deposits of both remain unchanged ( This is the consistency of business logic , The integrity of database relational constraints is better understood ). Safeguard mechanism ( Also from two aspects ): Database level Before and after a transaction is executed , The data will match your settings constraint ( Unique constraint , Foreign key constraints ,check constraint etc. ) And trigger settings ; Besides , The internal data structure of the database ( Such as B Tree index or double linked list ) Must be right . Business consistency is generally guaranteed by developers , It can also be transferred to the database level .
3. Isolation,
When multiple transactions are accessed concurrently , Transactions are isolated , A transaction should not affect the running effect of other transactions . In a concurrent environment , When Different transactions manipulate the same data at the same time when , Every transaction has Their complete data space . Changes made by concurrent firms must be isolated from changes made by any other concurrent firms . When transactions view data updates , The state of the data is either the state of another transaction before it was modified , Or another transaction changes its state , Transactions do not see data in the intermediate state . The most complex problems of transactions are caused by transaction isolation . Complete isolation is unrealistic , Complete isolation requires the database to execute only one transaction at a time , This can seriously affect performance . About the transaction isolation level in isolation ( The impact between transactions ), See the corresponding blog
4. persistence
This is one of the best understood features : persistence , It means after the transaction is completed , Changes made by the firm to the database are persisted in the database , It will not be rolled back .( The completed transaction is Permanent part of the system , The impact on the system is permanent , This modification will remain unchanged even if there is a fatal system failure ) write ahead logging:SQL Server Used in WAL(Write-Ahead Logging) Technology to ensure the of transaction log ACID characteristic , Before data is written to the database , Write to the log first , Then change the log record to memory .
2. MVCC
3. Five constraints
1、 Primary key constraint (Primay Key Coustraint) Uniqueness , Non emptiness 2、 Unique constraint (Unique Counstraint) Uniqueness , Can be empty , But only one 3、 Check constraint (Check Counstraint) The range of data in this column 、 Format restrictions ( Such as : Age 、 Gender, etc ) 4、 Default constraint (Default Counstraint) The default value of this data 5、 Foreign key constraints (Foreign Key Counstraint) You need to establish a relationship between the two tables and reference the columns of the main table
4. conceptual model
- conceptual model :
- Definition : The first level of abstraction from the real world to the information world , Determine the attribute relationship of domain entities, etc .
- Representation :E-R chart .
- logical model :
- Definition :
- Transform a conceptual model into a data model .
- According to the selected DBMS, take E-R The diagram is transformed into the corresponding logical model .
- The essence :E-R The transformation from graph to relational model is to solve how to transform entities and relationships between entities into relationships , And determine the attributes and codes of these relationships .
- Transformation rules :
- An entity is transformed into a relationship , The attributes of entities are the attributes of relationships , The code of entity is the code of relation .
- A connection is also transformed into a relationship , The attribute of the relation and the code of the entity to which the relation is connected are converted into the attribute of the relation , But the code of the relationship will change according to the type of connection , If it is : 1:1 contact , The codes of both entities become the candidate codes of the relationship . 1:n contact ,n The code of the end entity becomes the code of the relationship . m:n contact , The combination of entity codes at both ends becomes the code of relationship .
- Definition :
- The physical model :
- Definition : The logical model corresponds to the machine implementation of the specific data model .
- The essence : A physical model is a description of a real database .
- For example, some objects in relational database are tables 、 View 、 Field 、 data type 、 length 、 Primary key 、 Foreign keys 、 Indexes 、 constraint 、 Can it be empty 、 The default value is .
5. Three paradigms
- A normal form guarantees the atomicity of each column All field values in the database table are indecomposable atomic values
- Second normal form : Make sure that a table describes only one thing Eliminate dependencies between non primary attributes
- Third normal form ---- Ensure that each column is directly related to the primary key Eliminate delivery dependency
Post Views: 397
边栏推荐
猜你喜欢

E-commerce is popular, how to improve the store conversion rate?
![[width first search note] BFS output shortest path](/img/b5/553ca241ae571daecabd282f33f20a.jpg)
[width first search note] BFS output shortest path

Use of axurer9 master

Description détaillée du schéma technique du sous - environnement syntonique auto - test de Zadig pour les développeurs

电商秒杀系统架构设计

Progress in visual weakly supervised learning

Analysis of CSRF Cross Site Request Forgery vulnerability

华为云的AI深潜之旅

Zero foundation self-study SQL course | complete collection of date functions in SQL
![Sword finger offer:[day 1 stack and queue (simple)] --- > stack containing min function](/img/16/2edfc478a56e5b5e7299621ac778c2.jpg)
Sword finger offer:[day 1 stack and queue (simple)] --- > stack containing min function
随机推荐
Architecture design of e-commerce secsha system
Constructing the three-dimensional anti penetration of the actual combat defense system
Set when quartz scheduled task trigger starts
Quartz定时任务触发器启动时设置
职业问诊 | 在数据分析面试中,这样做自我介绍才靠谱
10、标准I/O输入输出重定向及管道
LxC shared USB device
【HackTheBox】dancing(SMB)
Ctrip will push the "3+2" working mode: 3 days a week on duty and 2 days of free choice of office space. Do you envy it?
Golang JSON serializing and deserializing strings deserializing to map[string]interface{}
现在还能入“坑”数据分析吗?看看2022年数据分析热门岗位!
Axure custom components
Wechat applet realizes left sliding deletion
视觉弱监督学习研究进展
Move the mouse out of the selected area style cancel
IPv6 comprehensive experiment
How to open a safe and reliable securities account in the financial management class of qiniu school?
Google search is dying | DKB
How do independent site sellers efficiently manage complex Facebook pages?
Webrtc audio and video development - experience