当前位置:网站首页>MySQL - MySQL 三范式理解
MySQL - MySQL 三范式理解
2022-08-06 04:10:00 【Chon-Wang】
一、第一范式
1NF是要求 每列 具有原子性,不可再分解;即每列的内容不可被分割。
例: 一个表字段,
address字段, 存储内容为省市区-详细地址。如果项目环境,经常按 省市区 搜索 ,这就不符合第一范式。因为可以拆成
省、市、区、详细地址四个字段。
二、第二范式
2NF要求在符合 第一范式 的基础上, 实现实体的唯一性;即一张表只描述一件事情。
例:订单信息表中,只保留
订单ID、用户ID、收件人姓名、收件人地址、收件人手机号、订单备注等 用户信息 与 收件人信息 的字段, 不可出现订单商品信息、订单状态信息等。可以分为
订单信息表、订单商品表、订单状态表、退货表等。
三、第三范式
3NF要求在符合 第二范式 的基础上, 要求 非主键的列只依赖于主键;第三范式与第二范式有些像,只不过所描述的内容不一样。一个描述的是一个表应该只作用于一种环境需求,一个描述的是 除主键外,每个字段只能通过主键关联。
例: 订单信息表中,只保留
用户ID的一个用户信息 字段,就不能再出现 用户性别、用户出生年月 等字段。因为 性别、出生年月 无法与 订单表主键关联并且识别出是哪位用户,所以只能通过 用户ID 来绑定。
但根据实际场景需求,比如订单信息页面, 需要显示 用户的真实姓名, 且 用户的真实姓名是不可改的, 那就可以在 订单信息表 中创建一个 用户真实姓名 的冗余字段。
边栏推荐
- 力扣------分数排名
- 《论文阅读》EmpTransfo: A Multi-head Transformer Architecture for Creating Empathetic Dialog Systems
- P1058 [NOIP2008 普及组] 立体图
- 数字孪生实际应用案例-智慧港口篇
- Custom View, and the usage of Canvas (canvas), Paint (brush), Path (path)
- 什么是Egg.js,它有什么特性,egg框架的安装,路由的定义,控制器Controller是什么,CORS配置,JSONP配置,get请求,post请求
- 双机热备技术(讲解+实验)——静态路由实现
- Programmer's first day at work | Daily anecdote
- Jvm: synchronized锁定谁?
- 一键解锁,2022阿里顶会创新技术前沿进展
猜你喜欢

【wpf】依赖属性三个回调详解

2023 6th International Conference on Advanced Control, Automation and Robotics (ICACAR 2023)

Datax及Datax-web 下载使用

造自己的芯,让谷歌买单!谷歌再度开源 180nm 工艺的芯片

“模组+天线”全栈解决方案,提速物联网终端高效部署

Pytorch入门实战(5):基于nn.Transformer实现机器翻译(英译汉)
![[Deep Learning 21 Days Learning Challenge] Memo: Model Reuse - Model Saving and Loading](/img/1d/3b076809692c81c5446a3a93d8fdfd.png)
[Deep Learning 21 Days Learning Challenge] Memo: Model Reuse - Model Saving and Loading

2022 Practical Content Course on Building Modern Web Applications with Go

项目day(3) 前台环境搭建

如何写好代码
随机推荐
2023 6th International Conference on Data Mining and Knowledge Discovery (DMKD 2023)
自定义View,和Canvas(画布),Paint(画笔),Path(路径)的用法
Advantages and disadvantages of solid tires
用户认证——Kerberos部署
[C language array subscript out of bounds] Infinite loop caused by array subscript out of bounds
Getui data intelligence technology practice | Teach you to create data quality ECG, intelligently detect abnormal data "heartbeat"
【LaTex】 - How to use the alignment symbol &, the usage of the newline character \\, how to solve the Misplaced & error
Simple sample code of google's lightweight DI framework guice
Internet protocol overview
项目day(3) 前台环境搭建
【语义分割】2019-DANet CVPR
Practical and bytes to beat Flink status query optimization
Routing policy in redistribution:
译文推荐|深入解析 BookKeeper 协议模型与验证
Do I need to exclude old campaigns for new country campaigns?
个推数据智能技术实践 | 教你打造数据质量心电图,智能检测数据“心跳”异常
[Binary tree] The number of nodes whose statistical value is equal to the average value of the subtree
Translation recommendation|In-depth analysis of BookKeeper protocol model and verification
Sorting out the knowledge system of fully homomorphic encryption
Niu Ke topic - the best time to buy and sell stocks (1), (2), (3), design LRU cache structure