当前位置:网站首页>MySQL database design specification
MySQL database design specification
2022-08-02 07:51:00 【kk_lina】
I. Paradigm
1, 5 paradigms
- First Normal Form: atomic and cannot be split;
- Second normal form: Each data record in the data table can be uniquely identified, and non-primary key fields completely depend on the primary key.A table is an object for its own independent meaning.
- Third normal form: other non-primary key fields in the table cannot depend on other non-primary key fields, that is, non-dependent transitivity;
- Bath-Kord normal form (third normal form after optimization): the third normal form is reached, and there is only one candidate key, or each candidate key is a single attribute;
- Fourth Normal Form: Eliminate non-trivial and functionally dependent multi-value dependencies, that is, eliminate many-to-many relationships in the same table;
- Fifth Normal Form (5NF, perfect normal form): If every join dependency in a relational schema R is implied by a candidate key of R.
2. The advantages and disadvantages of the paradigm:
- Benefit: Eliminate data redundancy
- Disadvantages: reduce query efficiency, multi-table association, may be the index strategy failure
3. Denormalization
Some data may seem redundant, but they are suitable for business and need to be prioritized. At this time, de-normalization is required.
There may be a conflict between normalization and performance. You can add redundant fields to the table to reduce search time, or insert calculated columns to facilitate query.
Second, keys and related attributes
- Super key: a set of attributes that can uniquely identify a tuple;
- Candidate key: If the super key does not include redundant attributes, then this super key is the candidate key;
- Primary key: the user can choose one of the candidate keys;
- Foreign key: an attribute in one table is not the primary key of this table but the primary key of another table
- Main attribute: the main attribute involved in the candidate key
- Non-primary attribute: relative to primary attribute
Three, ER model
1. Three elements
- Entity: A data object, which can exist independently, usually a data table, represented by a rectangle;
- Attribute: the characteristics of the entity, usually a field, represented by an ellipse;
- Relation: The connection between entities, represented by a diamond.
2. Types of relationships
- One to One
- One-to-many
- Many-to-many
3. Convert the ER model diagram into a data table
- An entity is usually converted into a data table;
- A many-to-many relationship is usually also converted into a data table;
- A one-to-one relationship, or a one-to-many relationship, is usually expressed by converting it into a table's foreign key, rather than designing a new data table;
- attributes are converted into table fields.
边栏推荐
猜你喜欢
随机推荐
Xilinx约束学习笔记—— 时序约束
实例030:回文数
CollectionUtil:一个函数式风格的集合工具
神经元网络
逆变器锁相原理及DSP实现
Link with Game Glitch
LeetCode 2360. 图中的最长环
2022.07.31(LC_6133_分组的最大数量)
Splunk Field Caculated Calculated Field
第06章 索引的数据结构【2.索引及调优篇】【MySQL高级】
【红队】ATT&CK - 创建或修改系统进程实现持久化(更新ing)
企业实训复现指导手册——基于华为ModelArts平台的OpenPose模型的训练和推理、基于关键点数据实现对攀爬和翻越护栏两种行为的识别、并完成在图片中只标注发生行为的人
OC-error prompt
有关 sql中的 concat()函数问题,如何拼接
【机器学习】实验6布置:基于集成学习的Amazon用户评论质量预测
使用hutool做本地缓存的工具类
OC-NSString
MySQL-数据库事务详解
FormData上传二进制文件、对象、对象数组
队列题目:无法吃午餐的学生数量