Home Database Mysql Tutorial 数据库的范式理论

数据库的范式理论

Jun 07, 2016 pm 03:06 PM
key super relation database theory paradigm

先扫盲: 超键(super key): 在关系中能唯一标识元组的属性集称为关系模式的超键 候选键(candidate key) :不含有多余属性的超键称为候选键 主键(primary key) :用户选作元组标识的一个候选键程序主键 比如一个小范围的所有人,没有重名的,考虑以下属性 身份

先扫盲:

超键(super key):在关系中能唯一标识元组的属性集称为关系模式的超键
候选键(candidate key):不含有多余属性的超键称为候选键
主键(primary key):用户选作元组标识的一个候选键程序主键

比如一个小范围的所有人,没有重名的,考虑以下属性

身份证  姓名  性别 年龄

身份证唯一,所以是一个超键
姓名唯一,所以是一个超键
(姓名,性别)唯一,所以是一个超键
(姓名,性别,年龄)唯一,所以是一个超键
--这里可以看出,超键的组合是唯一的,但可能不是最小唯一的

身份证唯一,而且没有多余属性,所以是一个候选键
姓名唯一,而且没有多余属性,所以是一个候选键
--这里可以看出,候选键是没有多余属性的超键

考虑输入查询方便性,可以选择 身份证 为主键
也可以 考虑习惯 选择 姓名 为主键
--主键是选中的一个候选键

-----------------------------------------------------------------------

第一范式:

所有的属性都是不可分割的原子单位

第二范式:

如果关系模式R(U,F)中的所有非主属性都完全依赖于任意一个候选关键字,则称关系R 是属于第二范式。

第三范式:

如果关系模式R(U,F)中的所有非主属性对任何候选关键字都不存在传递信赖,则称关系R是属于第三范式的

BC范式:(BCNF)

如果关系模式R(U,F)的所有属性(包括主属性和非主属性)都不传递依赖于R的任何候选关键字,那么称关系R是属于BCNF的。

举例说明:

第一范式(1NF):

如果关系模式R的每个关系都是r的属性值不可分割的原子值,则称关系R是第一范式的模式.

  不满足第一范式的情况:
  关系R(name,address,phone)
  ----------------------------------------------------------------------
  name address phone

AA 山西太原 2204446
   AA 山西太原 8350524
  ----------------------------------------------------------------------
说明:phone可以再分(可以分为phone1和phone2).

*************************************************************************************

第二范式(2NF):

1):局部依赖:
  对于依赖关系 W->A (A依赖于W),如果存在X归属于W,且X->A(A依赖于X),那么称W->A是局部依赖;否则称W->A是完全依赖.
  比如:
  关系模式R(sno,cno,grade,tname,taddr)
  sno:学生学号;cno:课程编号;grade:成绩;tname:老师姓名;taddr:老师住址
  (sno,cno)->(tname,taddr)(sno,cno决定于tname以及cno)是局部依赖,因为cno->(tname,taddr).

2):二范式定义:
  如果关系模式R满足第一范式,且每个非主属性完全依赖于侯选键,则称R满足第二范式.

不满足第二范式的情况:
  关系模式R(sno,cno,grade,tname,taddr)
  sno:学生学号;cno:课程编号;grade:成绩;tname:老师姓名;taddr:老师住址
  ----------------------------------------------------------------------
  sno cno grade tname taddr

  101 001 100 张老师 山西太原....
  102 001 95 张老师 山西太原....
  103 001 98 张老师 山西太原....
  104 002 95 李老师 中国北京....
  105 003 90 刘老师 中国上海....
  ----------------------------------------------------------------------
  说明:出现相同的tname,taddr三次
  消除方法:分解关系模式R
  ----------------------------------------------------------------------
  R1(sno,cno,grade)

  sno cno grade

  101 001 100
  102 001 95
  103 001 98
  104 002 95
  105 003 90


  R2(cno,tname,taddr)

  cno tname taddr

  001 张老师 山西太原....
  002 李老师 中国北京....
  003 刘老师 中国上海....
  ----------------------------------------------------------------------

*************************************************************************************

第三范式(3NF):

1):传递依赖:如果X->Y,Y->A,且Y不依赖X和A不是Y的子集,那么称X->A是传递依赖.(A传递依赖于X)

2):三范式定义:
  如果关系模式R是1NF,且每个非主属性都不依赖于R的侯选键,那么称R满足第三范式.

不满足第三范式的情况:
  关系模式R2(cno,tname,taddr)是2NF模式,如果在R2中存在cno->tname,tname->taddr,那么cno->taddr就是个传递依赖,及不满足第三范式.
  ----------------------------------------------------------------------
  cno tname taddr

  001 张老师 山西太原....
  002 李老师 中国北京....
  003 刘老师 中国上海....
  004 张老师 山西太原....
  005 张老师 山西太原....
  ----------------------------------------------------------------------
  说明:张老师开设了3门课程,上面就出现了3个元组,教师地址重复了3次.
  消除方法:分解关系模式R2
  ----------------------------------------------------------------------
  R3(cno,tname)

  cno tname

  001 张老师
  002 李老师
  003 刘老师
  004 张老师
  005 张老师

  R4(tname,taddr)

  tname taddr

  张老师 山西太原....
  李老师 中国北京....
  刘老师 中国上海....
  ----------------------------------------------------------------------

再补充一下:

第四范式(4NF)

第四范式禁止主键列和非主键列一对多关系不受约束

第五范式(5NF)

第五范式将表分割成尽可能小的块,为了排除在表中所有的冗余.

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Breaking through the boundaries of traditional defect detection, 'Defect Spectrum' achieves ultra-high-precision and rich semantic industrial defect detection for the first time. Breaking through the boundaries of traditional defect detection, 'Defect Spectrum' achieves ultra-high-precision and rich semantic industrial defect detection for the first time. Jul 26, 2024 pm 05:38 PM

In modern manufacturing, accurate defect detection is not only the key to ensuring product quality, but also the core of improving production efficiency. However, existing defect detection datasets often lack the accuracy and semantic richness required for practical applications, resulting in models unable to identify specific defect categories or locations. In order to solve this problem, a top research team composed of Hong Kong University of Science and Technology Guangzhou and Simou Technology innovatively developed the "DefectSpectrum" data set, which provides detailed and semantically rich large-scale annotation of industrial defects. As shown in Table 1, compared with other industrial data sets, the "DefectSpectrum" data set provides the most defect annotations (5438 defect samples) and the most detailed defect classification (125 defect categories

NVIDIA dialogue model ChatQA has evolved to version 2.0, with the context length mentioned at 128K NVIDIA dialogue model ChatQA has evolved to version 2.0, with the context length mentioned at 128K Jul 26, 2024 am 08:40 AM

The open LLM community is an era when a hundred flowers bloom and compete. You can see Llama-3-70B-Instruct, QWen2-72B-Instruct, Nemotron-4-340B-Instruct, Mixtral-8x22BInstruct-v0.1 and many other excellent performers. Model. However, compared with proprietary large models represented by GPT-4-Turbo, open models still have significant gaps in many fields. In addition to general models, some open models that specialize in key areas have been developed, such as DeepSeek-Coder-V2 for programming and mathematics, and InternVL for visual-language tasks.

Training with millions of crystal data to solve the crystallographic phase problem, the deep learning method PhAI is published in Science Training with millions of crystal data to solve the crystallographic phase problem, the deep learning method PhAI is published in Science Aug 08, 2024 pm 09:22 PM

Editor |KX To this day, the structural detail and precision determined by crystallography, from simple metals to large membrane proteins, are unmatched by any other method. However, the biggest challenge, the so-called phase problem, remains retrieving phase information from experimentally determined amplitudes. Researchers at the University of Copenhagen in Denmark have developed a deep learning method called PhAI to solve crystal phase problems. A deep learning neural network trained using millions of artificial crystal structures and their corresponding synthetic diffraction data can generate accurate electron density maps. The study shows that this deep learning-based ab initio structural solution method can solve the phase problem at a resolution of only 2 Angstroms, which is equivalent to only 10% to 20% of the data available at atomic resolution, while traditional ab initio Calculation

Google AI won the IMO Mathematical Olympiad silver medal, the mathematical reasoning model AlphaProof was launched, and reinforcement learning is so back Google AI won the IMO Mathematical Olympiad silver medal, the mathematical reasoning model AlphaProof was launched, and reinforcement learning is so back Jul 26, 2024 pm 02:40 PM

For AI, Mathematical Olympiad is no longer a problem. On Thursday, Google DeepMind's artificial intelligence completed a feat: using AI to solve the real question of this year's International Mathematical Olympiad IMO, and it was just one step away from winning the gold medal. The IMO competition that just ended last week had six questions involving algebra, combinatorics, geometry and number theory. The hybrid AI system proposed by Google got four questions right and scored 28 points, reaching the silver medal level. Earlier this month, UCLA tenured professor Terence Tao had just promoted the AI ​​Mathematical Olympiad (AIMO Progress Award) with a million-dollar prize. Unexpectedly, the level of AI problem solving had improved to this level before July. Do the questions simultaneously on IMO. The most difficult thing to do correctly is IMO, which has the longest history, the largest scale, and the most negative

Nature's point of view: The testing of artificial intelligence in medicine is in chaos. What should be done? Nature's point of view: The testing of artificial intelligence in medicine is in chaos. What should be done? Aug 22, 2024 pm 04:37 PM

Editor | ScienceAI Based on limited clinical data, hundreds of medical algorithms have been approved. Scientists are debating who should test the tools and how best to do so. Devin Singh witnessed a pediatric patient in the emergency room suffer cardiac arrest while waiting for treatment for a long time, which prompted him to explore the application of AI to shorten wait times. Using triage data from SickKids emergency rooms, Singh and colleagues built a series of AI models that provide potential diagnoses and recommend tests. One study showed that these models can speed up doctor visits by 22.3%, speeding up the processing of results by nearly 3 hours per patient requiring a medical test. However, the success of artificial intelligence algorithms in research only verifies this

To provide a new scientific and complex question answering benchmark and evaluation system for large models, UNSW, Argonne, University of Chicago and other institutions jointly launched the SciQAG framework To provide a new scientific and complex question answering benchmark and evaluation system for large models, UNSW, Argonne, University of Chicago and other institutions jointly launched the SciQAG framework Jul 25, 2024 am 06:42 AM

Editor |ScienceAI Question Answering (QA) data set plays a vital role in promoting natural language processing (NLP) research. High-quality QA data sets can not only be used to fine-tune models, but also effectively evaluate the capabilities of large language models (LLM), especially the ability to understand and reason about scientific knowledge. Although there are currently many scientific QA data sets covering medicine, chemistry, biology and other fields, these data sets still have some shortcomings. First, the data form is relatively simple, most of which are multiple-choice questions. They are easy to evaluate, but limit the model's answer selection range and cannot fully test the model's ability to answer scientific questions. In contrast, open-ended Q&A

PRO | Why are large models based on MoE more worthy of attention? PRO | Why are large models based on MoE more worthy of attention? Aug 07, 2024 pm 07:08 PM

In 2023, almost every field of AI is evolving at an unprecedented speed. At the same time, AI is constantly pushing the technological boundaries of key tracks such as embodied intelligence and autonomous driving. Under the multi-modal trend, will the situation of Transformer as the mainstream architecture of AI large models be shaken? Why has exploring large models based on MoE (Mixed of Experts) architecture become a new trend in the industry? Can Large Vision Models (LVM) become a new breakthrough in general vision? ...From the 2023 PRO member newsletter of this site released in the past six months, we have selected 10 special interpretations that provide in-depth analysis of technological trends and industrial changes in the above fields to help you achieve your goals in the new year. be prepared. This interpretation comes from Week50 2023

iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos Jul 18, 2024 am 05:48 AM

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

See all articles