当前位置:网站首页>Soft test -- software designer -- database design of afternoon questions
Soft test -- software designer -- database design of afternoon questions
2022-06-28 07:43:00 【No. 1006 Xiaobai】
Database design
put questions to
Usually :
- Supplementary entity contact diagram
- Supplementary logic structure design (a)(b) The constraints of vacancy and completeness
- Analyze the primary key and foreign key of the relational schema
- The last question depends on the situation
1、 Physical contact diagram
How severe : The types of contact can be divided into :
one-on-one (1:1)
One to many (1:n)/ 1:*Many to many (n:m) / * : *
How severe :0,1 On behalf of 0 perhaps 1 individual ,* It means at least oneContact name : Usually the title will say that you can use the connection 1, contact 2, contact 3 replace , If you don't say it, just look at the expression used in the title
put questions to , Give an example to illustrate 


There are three steps to judge the severity
The title says : There are many employees in each department , Each employee can only belong to one department
When we judge how serious the relationship between the Department and the employees is
1、 Let's write a department first , Corresponding to multiple employees , department : staff =1:n
2、 Then judge that an employee belongs to only one department , staff : department = 1:1
3、 Combine the two , department : staff = 1 :n

Here is a supplementary point , The manager is a kind of employee , Employees are super class , Managers are subclasses , It can be understood as inheritance , Then the manager used the above expression , There is a circle on the connecting line , A rectangle has vertical lines on both sides , R & D personnel 、 salesman 、 Supervisors are subclasses
There is also a weak entity ( One entity must depend on another entity to exist ), Use two rectangular boxes to represent
The following transcript is the weak entity of the student

2、 Logical structure design (a)(b) The constraints of vacancy and completeness


One by one
The branch office is still short of managers 、 The Department lacks the supervisor number , Branch number 、 Employees lack the subordinate departments 、 Position
(a) The manager
(b) Supervisor number , Branch number
(c) Subordinate departments 、 Position
This problem just turns out to be this , But when we are designing the logic structure , Pay attention to how severe
1 Yes 1: Add the primary key of one entity to the relationship schema of another entity
1 For more than : Add the primary key of an entity to the relationship pattern of multiple entities
Many to many : Turn the connection between them into an entity , Then add the primary keys of many to many entities 

Training is the connection between new employees and courses , And it is a many to many relationship , Turn the connection into an entity
train ( Course no. 、 New employees 、 achievement ) The reason why there are achievements , Because of the description in the title , You will get good results during the training , Performance itself is the attribute of training


A small summary : A two-step , One is to compare with the text to see what is missing , The second one is more serious
3、 Primary keys and foreign keys
Integrity constraints : In fact, you should write their primary key and foreign key
Add
Database integrity constraints :
1. It is divided into entity integrity : Define the primary key
2. Referential integrity : Foreign keys
3. User-defined integrity : Attribute constraints
A primary key is a key that uniquely identifies each tuple , I can only find unique information according to the primary key , If the title clearly states the unique identifier , This means that this is the primary key , If not, you should pay attention to whether it is a composite primary key 
Primary key of branch No : Branch number
Department relationship PK : Department number
Employee relations : Employee number
Foreign keys , When we are looking for foreign keys , Look at the relationship pattern , What are in other relationship models , Can be understood as a foreign key , If it is a self-contained attribute, it is not a foreign key , For example, the performance we just mentioned is the attribute of training , Results are not foreign keys For example, the subordinate department in the employee number
In fact, it corresponds to the contents in the department number
So the foreign key of the employee number is the department number
summary :
Physical contact diagram : Judge how strong the connection is
Relationship model : one-on-one , See how heavy
Main foreign key : Look at the relationship pattern , You can also compare the severity
Almost every sentence in the text is useful , So when you look at the topic again, you must observe carefully
If you think it's OK, just like it
边栏推荐
猜你喜欢

8 figures | analyze Eureka's first synchronization registry

Source code analysis of kubernetes' process of deleting pod

推荐系统系列精讲(第五讲): 排序模型的调优实践

Mysql57 zip file installation

linux下修改mysql端口号

Static resource compression reduces bandwidth pressure and increases access speed

golang gin框架进行分块传输

什么是EC鼓风机(ec blower fan)?

A single node obtains the lock lock of the order number

以动态规划的方式求解最长回文子串
随机推荐
How to configure DDR3 of dm8148
HJ string sort
Modifying MySQL port number under Linux
Application of XOR. (extract the rightmost 1 in the number, which is often used in interviews)
股票炒股注册开户靠谱吗?安全吗?
打新债注册开户靠谱吗?安全吗?
Real time database - Notes
"Three routines" of digital collection market
Co process, asyncio, asynchronous programming
pip 更新到最新的版本
Hash slot of rediscluster cluster cluster implementation principle
HJ成绩排序
Llvm and clang
HJ删除字符串中出现次数最少的字符
R language drawing ggplot2 seasonal graph
Hj21 simple password
自动化测试的生命周期是什么?
Is it reliable to register and open an account for stock speculation? Is it safe?
Section Xi. Axi of zynq_ Use of DMA
SOC clock configuration