识别功能依赖性 II
这是一个示例,应该可以澄清上一篇文章的内容。
雇佣日期& carReg 是主键。除了我已经确定的功能依赖项之外,是否还存在额外的功能依赖项 (FD) 以下?也欢迎修改:
fd1 carReg -> make, model, outletNo, outletLoc
fd2 custNo -> custName
fd3 outletNo -> outletLoc
fd4 model -> make (only if we assume a model name is unique to a make)
fd5 carReg, hireDate -> make, model, custNo, custName, outletNo, outletLoc
我不确定以上内容是否正确,但我确信还有更多。
基于Mike Sherrill Cat Recall的回答 ...我的问题是这样的: custName -> 怎么样?客户没有有效的FD?对于上述关系,当然,一个客户名称恰好映射到一个客户编号,但凭直觉,我们知道可以将多个 J SMith 添加到表中。如果是这种情况,则该 FD 无效,因为它形成 1..* 关系。我们真的可以说 custName ->客户不知道这个事实吗?我们是否仅仅将 FD 建立在样本数据的基础上?或者我们是否考虑到可以添加的可能值?
Here is an example which should clear things up for the last post.
hireDate & carReg are the primary keys. Are there extra functional dependencies (FDs) other than the ones I have identified
below? Modifications also welcome:
fd1 carReg -> make, model, outletNo, outletLoc
fd2 custNo -> custName
fd3 outletNo -> outletLoc
fd4 model -> make (only if we assume a model name is unique to a make)
fd5 carReg, hireDate -> make, model, custNo, custName, outletNo, outletLoc
I'm not sure if the above are correct and I am sure there are more.
Based on Mike Sherrill Cat Recall's answer... My question is this: How is custName -> custNo a valid FD? For the above relation, sure, a customer name maps onto exactly one customer number, but by intuition, we know more than one J SMith could be added to the table. If this is the case, this FD is void as it forms a 1..* relationship. Can we really say that custName -> custNo knowing this fact? Do we merely base FDs on the sample data? Or do we take into account the possible values that can be added?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
一目了然。 。 。
我确信还有其他人。示例数据不具有代表性,当您尝试从数据确定函数依赖关系时,这就是一个问题。假设您的示例数据只有一行。
FD 回答这一问题:“给定‘x’的一个值,我是否知道‘y’的一个且仅有一个值?”基于该单行样本数据集,每个属性都决定其他所有属性。 custNo 确定雇佣日期。雇佣日期决定了outletLoc。 custName 确定型号。
当样本数据不具有代表性时,很容易发现无效的 FD。您需要更具代表性的示例数据来清除一些无效的函数依赖性。
您可以使用 SQL 研究示例数据中的函数依赖性。
型号决定品牌吗?
三种不同的型号。 。 。
是的。每个型号都有一个品牌。根据样本数据,模型->制作。
carReg、custName 是否 ->雇用日期?
carReg 和 custName 的六种不同组合。
是的。 carReg 和 custName 的每个组合都有一个雇佣日期。所以根据样本数据,{carReg, custName} ->雇用日期。
At a glance . . .
And I'm sure there are others. The sample data isn't representative, and that's a problem when you try to determine functional dependencies from data. Let's say your sample data had only one row.
FDs answer the question, "Given one value for 'x', do I know one and only one value for 'y'?" Based on that one-row set of sample data, every attribute determines every other attribute. custNo determines hireDate. hireDate determines outletLoc. custName determines model.
When sample data isn't representative, it's easy to turn up FDs that aren't valid. You need more representative sample data to weed out some invalid functional dependencies.
You can investigate functional dependencies in sample data by using SQL.
Does model determine make?
Three distinct models . . .
Yup. One make for each model. Based on the sample data, model -> make.
Does carReg, custName -> hireDate?
Six distinct combinations of carReg and custName.
Yup. One hireDate for each combination of carReg and custName. So based on the sample data, {carReg, custName} -> hireDate.
好吧,既然你征求了第二个意见,我就给你一个。
第二种意见是第一种意见(CatCall 的)是完全正确的。
样本数据不足以识别/确定数据中的功能依赖性。识别/确定数据中的功能依赖性所需的是用户需求、数据库旨在支持的业务环境的描述/定义……
只有您的用户可以以一种或另一种方式告诉您应用了哪些功能依赖性。 (不要将此解释为您应该告诉用户他们应该告诉您“适用的 FD 是什么”,因为您的用户通常不知道该术语的含义。但是,适用的 FD 是什么,可以仍然只能从用户向您提供的业务规范中得出。)
(相反,PS 样本数据可能确实足以证明某个给定的 FD 肯定不适用。但这不是您的问题。)
Well, since you asked for a second opinion, I'll give you one.
The second opinion is that the first (CatCall's) is entirely correct.
Sample data do not suffice to identify/determine functional dependencies in the data. What is needed to identify/determine functional dependencies in the data, are user requirements, descriptions/definitions of the business environment the database is intended to support, ...
Only your users can tell you, one way or another, what functional dependencies apply. (Don't interpret this as meaning that you should be telling your users that they should be telling you "what the applicable FDs are", because your users will typically not know what the term means. However, what the applicable FDs are, can still be derived from nothing else than the business specs the user provides you with.)
(PS sample data may on the contrary indeed suffice to demonstrate that a certain given FD certainly will NOT apply. But that's not your question.)
FD(函数依赖)表示关系值或变量的某个属性。我们可以说它对于给定关系值成立或不成立(满足或不满足)(正确或不正确)。当我们说它对关系变量成立或不成立时,我们的意思是它对应用程序中可能出现的变量的每个可能值都成立或不成立。
另外,如果我们给定一个值并且我们被告知它满足的FD是可以保存它的变量满足的FD那么根据该假设该变量的FD是值的 FD。 (这有时被称为变量的“代表性数据”。)但是,如果我们只是给定一个变量可能出现的值,那么我们只知道
(形式为 S -> S 的子集)
(无论值如何,都必须保留,仅基于属性)
(值和变量必须相同)
从我的答案到我做错了什么? (从表中查找FD):
假设没有给出表变量的每个可能的表值,则确定表变量的FD需要其含义/谓词&给出的业务规则。
请参阅我对识别功能依赖项 (FD)。
A FD (functional dependency) expresses a certain property of a relation value or variable. We can say that it holds for or doesn't hold for (is satisfied by or isn't satisfied by) (is true of or is not true of) a given relation value. When we say it holds or doesn't hold for a relation variable we mean it holds or doesn't hold for every possible value for the variable that can arise in an application.
Also if we are given a value and we are told that the FDs it satisfies are the FDs that a variable that could hold it satisfies then by that assumption the variable's FDs are the value's FDs. (This is sometimes called "representative data" for the variable.) But if we are just given a value that might arise for a variable then we only know that
(the ones of the form S -> subset of S)
(the ones that must hold regardless of the value, based only on the attributes)
(which must be the same for the value & the variable)
From my answer to What did I do wrong? (Find FD from table):
Assuming not every possible table value for a table variable is given, determining FDs for a table variable requires its meaning/predicate & the business rules to be given.
See my answer to Identifying functional dependencies (FDs).
这是我对关系的尝试:
Here's my attempt at relationships: