Home Database Mysql Tutorial 边学边思考数据库中函数依赖与多值依赖的辨析

边学边思考数据库中函数依赖与多值依赖的辨析

Jun 07, 2016 pm 04:12 PM
What rely function review think us database

我们先复习下什么是函数:函数是发生在集合之间的一种对应关系(我喜欢用图理解) 数据库中讨论得比较多是非平凡函数依赖,而平凡意义不大) 因为成绩不是(学号,课程)的子集。 部分函数依赖:(学号,姓名)→ 性别 因为(学号,姓名)→ 性别 且 学号 →

我们先复习下什么是函数:函数是发生在集合之间的一种对应关系(我喜欢用图理解)

数据库中讨论得比较多是非平凡函数依赖,而平凡意义不大)

因为成绩不是(学号,课程)的子集。

部分函数依赖:(学号,姓名)→ 性别

因为(学号,姓名)→ 性别 且 学号 → 性别

完全函数依赖:(学号,课程号)→ 成绩

因为(学号,课程号)→ 成绩,学号 —\→ 成绩,课程号 —\→ 成绩。

传递函数依赖: 学号 → 系主任

因为学号 → 系名,系名 → 系主任 且 系名 —\→ 学号。

而多值依赖呢?给出定义

多值依赖的定义:
设R(U)是一个属性集合U上的一个关系模式,X, Y, 和Z是U的子集,并且Z=U-X-Y,多值依赖X->->Y成立当且仅当对R的任一个关系r,r在(X,Z)上的每个值对应一组Y的值,这组值仅仅决定于X值而与Z值无关。
若X->->Y,而Z=空集,则称X->->Y为平凡的多值依赖。否则,称X->->Y为非平凡的多值依赖。

依然用函数的映射关系来理解,引入f(x,y),假设f(x,y)=+-(x^),若z=f(x,y),则一个x值可以得出两个互为相反数的z。在这个二元函数关系中,y的取值事实上是不影响结果的。类比到关系模式上,即x为X集的属性值,y为Y集的属性值,z为Z集的属性值。

看看一个例子

(课程C) ——(教师T)—(参考书B)

数据库概率 —顾国生老师——数学分析
数据库概率 —顾国生老师——高等代数
数据库概率 —顾国生老师——微分方程

上述例子U{C,T,B},其中课程C和教师T唯一确定一组B,却与T无关,经由C决定,然而T并不是空集,所以是非平凡的多值依赖。

事实上,当T为空的时候,如果C中的每一个值c对应B中的一个确定的值,则变为函数依赖,所以函数依赖是多值依赖的一种特殊情况。

总计下:

1. 函数依赖不是指关系模式R的某个或某些关系实例满足的约束条件,而是指R的所有关系实例均要满足的约束条件。

2. 函数依赖是语义范畴的概念。只能根据数据的语义来确定函数依赖。(例如“姓名→年龄”这个函数依赖只有在不允许有同名人的条件下成立)

3. 函数依赖通常以集合抽闲出来讨论。

4. 数据库设计者根据需求对函数关系进行制定。例如认为“姓名→年龄”在特定表中可行。

5. 数据库设计者根据现实规定做强制要求。例如规定不允许同名人出现,函数依赖“姓名→年龄”成立。所插入的元组必须满足规定

的函数依赖,若发现有同名人存在, 则拒绝装入该元组。




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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

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)

Hot Topics

Java Tutorial
1662
14
PHP Tutorial
1261
29
C# Tutorial
1234
24
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

Complete collection of excel function formulas Complete collection of excel function formulas May 07, 2024 pm 12:04 PM

1. The SUM function is used to sum the numbers in a column or a group of cells, for example: =SUM(A1:J10). 2. The AVERAGE function is used to calculate the average of the numbers in a column or a group of cells, for example: =AVERAGE(A1:A10). 3. COUNT function, used to count the number of numbers or text in a column or a group of cells, for example: =COUNT(A1:A10) 4. IF function, used to make logical judgments based on specified conditions and return the corresponding result.

Detailed tutorial on establishing a database connection using MySQLi in PHP Detailed tutorial on establishing a database connection using MySQLi in PHP Jun 04, 2024 pm 01:42 PM

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

How to handle database connection errors in PHP How to handle database connection errors in PHP Jun 05, 2024 pm 02:16 PM

To handle database connection errors in PHP, you can use the following steps: Use mysqli_connect_errno() to obtain the error code. Use mysqli_connect_error() to get the error message. By capturing and logging these error messages, database connection issues can be easily identified and resolved, ensuring the smooth running of your application.

Things to note when Golang functions receive map parameters Things to note when Golang functions receive map parameters Jun 04, 2024 am 10:31 AM

When passing a map to a function in Go, a copy will be created by default, and modifications to the copy will not affect the original map. If you need to modify the original map, you can pass it through a pointer. Empty maps need to be handled with care, because they are technically nil pointers, and passing an empty map to a function that expects a non-empty map will cause an error.

How to use database callback functions in Golang? How to use database callback functions in Golang? Jun 03, 2024 pm 02:20 PM

Using the database callback function in Golang can achieve: executing custom code after the specified database operation is completed. Add custom behavior through separate functions without writing additional code. Callback functions are available for insert, update, delete, and query operations. You must use the sql.Exec, sql.QueryRow, or sql.Query function to use the callback function.

How to connect to remote database using Golang? How to connect to remote database using Golang? Jun 01, 2024 pm 08:31 PM

Through the Go standard library database/sql package, you can connect to remote databases such as MySQL, PostgreSQL or SQLite: create a connection string containing database connection information. Use the sql.Open() function to open a database connection. Perform database operations such as SQL queries and insert operations. Use defer to close the database connection to release resources.

How to save JSON data to database in Golang? How to save JSON data to database in Golang? Jun 06, 2024 am 11:24 AM

JSON data can be saved into a MySQL database by using the gjson library or the json.Unmarshal function. The gjson library provides convenience methods to parse JSON fields, and the json.Unmarshal function requires a target type pointer to unmarshal JSON data. Both methods require preparing SQL statements and performing insert operations to persist the data into the database.

See all articles