从功能依赖性确定密钥 [英] Determine Keys from Functional Dependencies

查看:151
本文介绍了从功能依赖性确定密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在读一个数据库理论课程,并​​且在我读完后我还不清楚我如何推断密钥,给定一组函数依赖。



我有一个示例问题:



查找与函数依赖关系R(ABCDEFG)的所有键

  AB→C 
CD→E
EF→G
FG→E
DE→C
BC→A

通过识别以下哪一个是关键来演示您的知识。

  a。 BCDEF 
b。 ADFG
c。 BDFG
d。 BCDE

有人可以告诉我如何分解函数依赖关系,关键?

解决方案

采取一种方法来解决这个问题,我需要了解如何处理这些问题。 FD AB→C



增加直到提及所有属性,例如ABDEFG→CDEFG(注意,这相当于ABDEFG→ABCDEFG,因为A-> A和B-> B是真的)。​​



这告诉你ABDEFG是一个超级密钥。



检查其他的LHS是你的超级密钥的子集,其RHS包含你的超级密钥的其他属性。 >

有两个。 EF→G和FG→E。从你的超级键中删除这些属性的RHS。这样做给你两个键,这当然是超级键,但不一定不可约的:ABDEF和ABDFG。



但是,从AB→C和CD→E,推导出ABD→E。因此,我们也可以从我们的ABDEF键中删除E。这里讨厌的事情是,当我说检查其他FD,这显然意味着你还应该检查出现在您的FDs集合(即任何FD,可以从您的给定的FD的集合中出现的任何FD) ...这是一个不切实际的手做...



这是一个有用的网站,用于验证您的结果是否正确:



http://www.koffeinhaltig.com/fds/ueberdeckung.php



您现在应该能够确定选项c是键。



UPDATE



链接现在损坏,不知道网站已经去了。也许你仍然可以找到一些有用的网站,跟踪互联网的历史。


I'm taking a database theory course, and it's not clear to me after doing the reading how I can infer keys, given a set of functional dependencies.

I have an example problem:

Find all keys of the relation R(ABCDEFG) with functional dependencies

AB → C
CD → E
EF → G
FG → E
DE → C
BC → A

Demonstrate your knowledge by identifying which of the following is a key.

a. BCDEF             
b. ADFG           
c. BDFG           
d. BCDE 

Can someone walk me through how I should decompose the functional dependencies to conclude that some combination of attributes is a key? I expect I'll face a number of these types of problems and I need to understand how to approach it.

解决方案

Take an FD, e.g. AB→C

Augment until all attributes are mentioned, e.g. ABDEFG → CDEFG (note that this is equivalent to ABDEFG → ABCDEFG because it is trivially true that A->A and B->B).

This tells you that ABDEFG is a superkey.

Check the other FDs in which the LHS is a subset of your superkey, and that on its RHS contains some other attribute of your superkey.

There are two. EF→G and FG→E. Remove the attributes of the RHS of these from your superkey. Doing so gives you two keys, that are certainly superkeys, but not necessarily irreducible ones: ABDEF and ABDFG.

However, from AB→C and CD→E we can also derive that ABD→E. Hence we can also remove the E from our ABDEF key. The nasty thing here is that when I said "Check the other FDs", that apparently means that you should also check any FD that appears in the closure of your set of FDs (i.e. any FD that is derivable from your given set of FDs)... And that's a bit impractical to do by hand ...

A useful site for verifying whether your results are correct :

http://www.koffeinhaltig.com/fds/ueberdeckung.php

You should now be able to determine that option c is a key.

UPDATE

link is now broken, no idea where the site has gone. Maybe you can still find something useful on sites that keep track of the history of the internet.

这篇关于从功能依赖性确定密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆