当前位置:网站首页>SQL database → constraint → design → multi table query → transaction
SQL database → constraint → design → multi table query → transaction
2022-07-27 05:25:00 【New an object_】
constraint
1. The concept of constraints
Constraints are rules that act on columns in a table , Used to limit the data added to the table
The existence of constraints ensures the correctness of elements in the database
2. Classification of constraints 
Foreign key constraints ( The physical connection )
Database design
What is database design ?
◆ What watches are there
◆ What fields are there in the table
◆ What is the relationship between tables
What kinds of table relationships are there ?
notes :ER chart (Entity Relationship)
eg:( Forum system ER chart )
Table relations
* one-on-one
* Such as : User and user details
* One to one relationships are mostly used for table splitting , Put the fields often used in an entity in a table , Infrequently used fields are placed in another table , Used to improve query performance
● Realization way : Add foreign keys on either side , Associate another party's primary key , And set the foreign key to be unique (UNIQUE)
* One to many ( For one more )
* Such as : Departments and employees
* A Department corresponds to multiple employees , One employee corresponds to one department *
● Realization way : Build foreign keys on more than one side , A primary key that points to a party of one
* Many to many :
* Such as : Goods and orders
* One item corresponds to multiple orders , An order contains multiple items
● Realization way : Create a third intermediate table , At least two foreign keys in the middle , Associate the primary keys of two parties respectively
Database design case 

analysis 

Multi-table query
1. Inner join query syntax 
2. External connection query syntax 
3. Subquery :
( Nested queries are called subqueries in queries )
Business
● Database transactions (Transaction) It's a mechanism 、 A sequence of operations , Contains a set of database operation commands
● Transactions submit or revoke requests to the system with all commands as a whole , That is, this set of database commands either succeed at the same time , Or fail at the same time
● Transaction is an indivisible logical unit
—— Open transaction
START TRANSACTION; perhaps BEGIN;
—— Commit transaction
COMMIT;
—— Roll back the transaction
ROLLBACK;
Four characteristics of business ( Frequently asked questions )
边栏推荐
- Create datasource using Druid connection pool
- Li Kou achieved the second largest result
- DBUtils
- 接收方设置并发量和限流
- JVM Part 1: memory and garbage collection -- runtime data area 4 - program counter
- JVM part I: memory and garbage collection part II -- class loading subsystem
- Gradio quickly builds ml/dl Web Services
- 李宏毅机器学习组队学习打卡活动day06---卷积神经网络
- JVM上篇:内存与垃圾回收篇九--运行时数据区-对象的实例化,内存布局与访问定位
- Typescript details
猜你喜欢
![[optical flow] - data format analysis, flowwarp visualization](/img/7d/2fefc32813ec0c93115e4b290b0944.png)
[optical flow] - data format analysis, flowwarp visualization

Shell course summary

Message reliability processing

JVM Part 1: memory and garbage collection part 9 - runtime data area - object instantiation, memory layout and access location

2021 OWASP top 4: unsafe design

JVM上篇:内存与垃圾回收篇十一--执行引擎

Idea remote debugging

JVM上篇:内存与垃圾回收篇七--运行时数据区-堆

How to test the payment process?

How to store the startprocessinstancebykey method in acticiti in the variable table
随机推荐
LeetCode之268.Missing number
B1027 print hourglass
Constraints of MySQL table
李宏毅机器学习组队学习打卡活动day05---网络设计的技巧
Interface and abstract class / method learning demo
During its low-level period, this slave edge causes the instruction number to make a corresponding model
2022 Zhengzhou light industry Freshmen's competition topic - I won't say if I'm killed
Inspiration from "flying man" Jordan! Another "arena" opened by O'Neill
B1029 old keyboard
JVM Part 1: memory and garbage collection part 10 - runtime data area - direct memory
How idea creates a groovy project (explain in detail with pictures and texts)
求组合数(最强优化)
How to sinicize the JMeter interface?
Message reliability processing
String class
实用小工具: Kotlin 代码片段
idea远程调试debug
JVM Part 1: memory and garbage collection part 8 - runtime data area - Method area
JVM Part 1: memory and garbage collection part 7 -- runtime data area heap
B1022 a+b in d-ary