当前位置:网站首页>Three paradigms of database design
Three paradigms of database design
2022-07-21 09:27:00 【Hua Weiyun】
One 、 Preface
In order to establish less redundancy 、 A well structured database , There are certain rules that must be followed when designing a database . In a relational database, such rules are called paradigms . A paradigm is a summary of a design requirement . To design a relational database with reasonable structure , Must meet certain paradigms .
There are three most common design paradigms in actual development :
Two 、 First normal form ( Make sure that each column remains atomic )
The first paradigm is the most basic paradigm . If all field values in the database table are atomic values that cannot be decomposed , It shows that the database table satisfies the first paradigm .
The reasonable following of the first paradigm needs to be determined according to the actual needs of the system . For example, some database systems need to use “ Address ” This attribute , Would have been “ Address ” Property is designed as a field of a database table . But if the system often accesses “ Address ” Attribute “ City ” part , Then we must “ Address ” This property is subdivided into provinces 、 City 、 Detailed address and other parts for storage , In this way, it is very convenient to operate on a certain part of the address . Only in this way can the design satisfy the first paradigm of database , As shown in the following table .
The user information shown in the above table follows the requirements of the first paradigm , In this way, it is very convenient for users to use cities for classification , It also improves the performance of the database .
3、 ... and 、 Second normal form ( Make sure that each column in the table is related to the primary key )
The second paradigm goes one step further than the first . The second paradigm needs to ensure that every column in the database table is related to the primary key , You can't just relate to a part of the primary key ( Mainly for the union primary key ). That is to say, in a database table , Only one kind of data can be saved in a table , It is not allowed to save multiple data in the same database table .
For example, to design an order information table , Because there may be many kinds of goods in the order , Therefore, the order number and the product number should be used as the joint primary key of the database table , As shown in the following table .
Order information sheet
So there's a problem : In this table, the order number and product number are used as the joint primary key . In this way, the commodity name in the table 、 Company 、 Commodity price and other information are not related to the primary key of this table , It's just about the item number . So it violates the design principle of the second paradigm .
If the order information table is split , Separate product information into another table , Separate the order item table into another table , It's perfect . As shown below .
This design , It greatly reduces the redundancy of the database . If you want to get the product information of the order , Use the commodity number to query the commodity information table .
Four 、 Third normal form ( Make sure that each column is directly related to the primary key column , Not indirectly )
The third paradigm needs to ensure that each column of data in the data table is directly related to the primary key , Not indirectly .
For example, when designing an order data table , The customer number can be used as a foreign key to establish a corresponding relationship with the order table . You can't add other information about customers to the order form ( Such as name 、 Company, etc ) Field of . The design shown in the following two tables is a database table that meets the third paradigm .
In this way, when querying the order information , You can use the customer number to refer to the records in the customer information table , You don't have to enter the customer information in the order information table many times , Reduced data redundancy .
边栏推荐
- Stay away from the market
- How to cut out only the people in the gait contour of the human body
- Summary and practice of MySQL optimistic lock (I)
- 如何使用 Node.js 访问 SAP HANA Cloud 数据库里的数据
- 一个典型的使用 SAP Cloud Application Programming 模型开发的 Fiori 应用
- 一文走进数据库设计三大范式
- 思源能否内置一个密码管理器
- Judge whether view slides in or out of the visible area of the screen
- 2022云计算技能比赛国赛最新资料
- New Crack:::CAD .NET 14.1.X
猜你喜欢
随机推荐
5W无线充SOC方案芯片FS68001封装SOP16和SOP8
MySQL password modification (teach you by hand)
SAP BTP 上 Roles,Roles collection 和 Scopes 的关联关系
什么是IFTMCS指示合同状态报文?
Baijiayun and Fuwei film, a US listed company, reached a merger agreement: priced at US $520million
WireShark 简介和抓包原理及过程
Dynamic kubernetes cluster capacity expansion of airbnb
Airbnb的动态kubernetes集群扩缩容
2012.4.13 360笔试总结
中国石墨上市:市值近12亿港元 实现鹤岗民营企业上市零突破
volley7–NetworkDispatcher从网络中获取数据[通俗易懂]
Gap Locks(间隙锁)
MySQL 悲观锁
【iCore4 双核心板_ARM】例程二十二:LWIP_UDP实验——以太网数据传输
如何更好地使用笔记本的触控板(Touchpad)
深度的思考
Observability improves the quality of software engineering, and observation cloud attends the 2022 qecon global software quality & effectiveness conference
土巴兔IPO被终止:年利润下降33% 经纬红杉是股东
关于 SAP Spartacus CSR fallback 之后,是否仍然会继续进行 SSR 的处理
How to cut out only the people in the gait contour of the human body