MySQL Series Database Design Three Paradigm Tutorial Examples

MySQL Series Database Design Three Paradigm Tutorial Examples

1. Knowledge description of the three paradigms of database design

1. What is a design paradigm?

The basis for designing tables is that tables designed according to these three paradigms will not have data redundancy.

2. Why should we learn the three database paradigms?

The database design paradigm is the specifications that the database design needs to meet. A database that meets these specifications is concise and has a clear structure. At the same time, no exceptions will occur in insert, delete, and update operations. On the contrary, it will be a mess, which will not only cause trouble for database programmers, but also be ugly and may store a lot of unnecessary redundant information.

Although we data analysts do not need to design the database ourselves, understanding the three database paradigms can be helpful for our understanding of the tables later.

3. What are the three paradigms?

1) First normal form: Any table should have a primary key, and each field should be atomic and indivisible.

insert image description here

2) Second normal form: It is based on the first normal form and requires that all non-primary key fields are completely dependent on the primary key and no partial dependency can occur.

insert image description here

Solution: Many-to-many, three tables, and two foreign keys in the relationship table.

insert image description here

3) Third normal form: built on the basis of the second normal form, all non-primary key fields directly depend on the primary key and cannot generate transitive dependencies.

insert image description here

Solution: One-to-many, two tables, add foreign keys to the multiple tables.

insert image description here

Note: Keep in mind the two sentences in blue above.

Reminder: In actual development, the main focus is on meeting customer needs, and sometimes redundancy is traded for execution speed.

2. Classic design scheme of database table

How to design one-to-one?

The first solution: primary key sharing

insert image description here

The second solution: foreign key unique

insert image description here

Note: The unique foreign key situation is a bit like the many-to-many situation described above. When the foreign key field is added with a
After the unique restriction, it becomes one-to-one.

The above is the detailed content of the MySQL series of database design three paradigm tutorial examples. For more information about the MySQL database design three paradigms, please pay attention to other related articles on 123WORDPRESS.COM!

You may also be interested in:
  • Detailed explanation of MySQL database paradigm
  • Mysql database design three paradigm examples analysis
  • Optimization of data tables in MySQL database, analysis of foreign keys and usage of three paradigms
  • Summary of MySQL database normalization design theory

<<:  A brief discussion on the difference between readonly and disable attributes of input in HTML

>>:  Introduction to the steps of deploying redis in docker container

Recommend

JS implements request dispatcher

Table of contents Abstraction and reuse Serial Se...

How to install MySQL 8.0 database on M1 chip (picture and text)

1. Download First of all, I would like to recomme...

Basic JSON Operation Guide in MySQL 5.7

Preface Because of project needs, the storage fie...

Installation tutorial of mysql 8.0.11 compressed version under win10

This article shares the installation tutorial of ...

Complete step-by-step record of MySQL 8.0.26 installation and uninstallation

Table of contents Preface 1. Installation 1. Down...

How to deploy Solidity smart contracts using ethers.js

If you have developed DApps on Ethereum, you may ...

CentOS 7 builds hadoop 2.10 high availability (HA)

This article introduces how to build a high-avail...

Let's talk about the two functions of try catch in Javascript

The program is executed sequentially from top to ...

A complete guide to clearing floats in CSS (summary)

1. Parent div defines pseudo-classes: after and z...

Use the sed command to modify the kv configuration file in Linux

sed is a character stream editor under Unix, that...

How to use nginx as a proxy cache

The purpose of using cache is to reduce the press...

How to use ES6 class inheritance to achieve a gorgeous ball effect

Table of contents introduce Implementation steps ...