数据库三范式想必大家并不陌生,官方的解释很抽象,初学者比较难理解。对于这块知识,我是看了会,会了忘,忘了再看。每当别人问我的时候,必须先看看教材,回顾一段时间才能理清。 为什么当别人提问时不能立马把三范式的经典思想说出来呢?通过听米老师的“
数据库三范式想必大家并不陌生,官方的解释很抽象,初学者比较难理解。对于这块知识,我是看了会,会了忘,忘了再看。每当别人问我的时候,必须先看看教材,回顾一段时间才能理清。
为什么当别人提问时不能立马把三范式的经典思想说出来呢?通过听米老师的“如何高效学习”这堂课,我发现原因是我自己没有融入到三范式中,三范式没有和自己发生关系。下面,我用三个有趣的小故事帮助大家快速、深刻的理解三范式的含义。
第一范式,官方解释:关系模式R的每个关系r的属性值都是不可分的原子值。这个官方解释还不算太难,比如我们想把“电话号码”作为数据库字段,在“电话号码”下面又分“手机号码”和“座机号码”,这就违反了第一范式,用我的话说就是“把事说清了”。你只说“电话号码”,我知道你说的是“手机号码”还是“座机号码”?
第二范式,官方解释:非主属性必须完全函数依赖于R的主关系键。怎么样,有点晕了吧!比如:在SCD表中,有字段SNO,SN,Age,Dept,MN,CNo,Score。知道SNo可以确定SN、Age、Dept、MN,知道SNo、CNo可以确定Score。这个事好比土匪们选大哥,小弟SN、Age、Dept、MN选举SNo当土匪头子,Score选举SNo、CNo两个人共同当土匪头子。结果意见达不成一致,土匪们闹分裂,一句话“只要有一个人不同意,这事就不能通过”。大哥SNo带着小弟SN、Age、Dept、MN成立土匪旗号SD,大哥SNo又和CNo带着小弟Score合伙成立土匪旗号SC,到此,故事告一段落。
第三范式,官方解释:每个非主属性都不传递函数依赖于R的主关系键。这个怎么样,彻底晕了吧!比如:在SD表中,知道SNo可以确定Dept,知道Dept可以确定MN(系主任名)。这事咱接着上面第二范式的土匪故事接着讲,大哥SNo有小弟SN、Age、Dept、MN,但Dept特别有才,又把MN招为自己的小弟,天天忽悠MN,给MN灌输反动思想,终于有一天Dept带着MN独立了,成立了土匪旗号D。大哥SNo感觉SD已经不完整了,把土匪旗号改为S。SNo经过这次教训,决定下道命令:“一个人只能扮演一个角色”,否则就是不符合三范式,造成关系模式分解。
到此故事讲完了,想必通过这个小故事,大家肯定把三范式的精髓深深的刻在了脑中。

InnoDBBufferPool reduces disk I/O by caching data and indexing pages, improving database performance. Its working principle includes: 1. Data reading: Read data from BufferPool; 2. Data writing: After modifying the data, write to BufferPool and refresh it to disk regularly; 3. Cache management: Use the LRU algorithm to manage cache pages; 4. Reading mechanism: Load adjacent data pages in advance. By sizing the BufferPool and using multiple instances, database performance can be optimized.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

MySQL is worth learning because it is a powerful open source database management system suitable for data storage, management and analysis. 1) MySQL is a relational database that uses SQL to operate data and is suitable for structured data management. 2) The SQL language is the key to interacting with MySQL and supports CRUD operations. 3) The working principle of MySQL includes client/server architecture, storage engine and query optimizer. 4) Basic usage includes creating databases and tables, and advanced usage involves joining tables using JOIN. 5) Common errors include syntax errors and permission issues, and debugging skills include checking syntax and using EXPLAIN commands. 6) Performance optimization involves the use of indexes, optimization of SQL statements and regular maintenance of databases.

MySQL is suitable for beginners to learn database skills. 1. Install MySQL server and client tools. 2. Understand basic SQL queries, such as SELECT. 3. Master data operations: create tables, insert, update, and delete data. 4. Learn advanced skills: subquery and window functions. 5. Debugging and optimization: Check syntax, use indexes, avoid SELECT*, and use LIMIT.

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL is an open source relational database management system that is widely used in Web development. Its key features include: 1. Supports multiple storage engines, such as InnoDB and MyISAM, suitable for different scenarios; 2. Provides master-slave replication functions to facilitate load balancing and data backup; 3. Improve query efficiency through query optimization and index use.

SQL is used to interact with MySQL database to realize data addition, deletion, modification, inspection and database design. 1) SQL performs data operations through SELECT, INSERT, UPDATE, DELETE statements; 2) Use CREATE, ALTER, DROP statements for database design and management; 3) Complex queries and data analysis are implemented through SQL to improve business decision-making efficiency.

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Atom editor mac version download
The most popular open source editor

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment