- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我在规范化方面遇到了一些问题。我有一个架构 REPAYMENT,它看起来像这样:
现在,根据我收集到的,架构中的功能依赖项是
{borrower_id} --> {name, address, request_date, loan_amount}
{request_date} --> {repayment_date, loan_amount}
{loan_amount] --> {repayment_amount}
(如果我错了请纠正我?)
我应该将架构规范化为 BCNF,但我有点困惑。候选键是request_date和borrower_id吗?
可用于登记小额贷款还款信息。借款人及其姓名和地址由唯一的 borrower_id 标识。借款人可以同时拥有多笔贷款,但每笔贷款(由 loan_amount、repayment_date 和 repayment_amount 指定)都有不同的请求日期。因此,可以使用借款人 ID 和贷款请求日期来识别贷款。借款人可以在同一天偿还多笔(不同的)贷款,但每笔贷款只能偿还一次(一次、一笔金额)。有一个系统可以针对每个请求日期和贷款金额确定还款日期和要偿还的金额。申请的贷款金额和偿还的金额不同,因为有适用的利率。
最佳答案
根据候选键的定义:
In the relational model of databases, a candidate key of a relation is a minimal superkey for that relation; that is, a set of attributes such that:
The relation does not have two distinct tuples (i.e. rows or records in common database language) with the same values for these attributes (which means that the set of attributes is a superkey)
There is no proper subset of these attributes for which (1) holds (which means that the set is minimal).
现在你的问题:
Is the candidate key request_date and borrower_id?
它是一个 super key ,但不是最小的。以下是我们如何计算候选键。
哪个属性只出现在左侧,考虑所有的 F 。 D?
ITS borrower_id。这意味着它必须是此给定模式的每个键的一部分。现在让我们计算它的闭包。
因为 {borrower_id} --> {name, address, request_date, loan_amount}:
closure(borrower_id) = borrower_id, name, address, request_date, loan_amount.
因为 {request_date} --> {repayment_date, loan_amount} 和 closure(borrower_id) 有 request_date,这意味着
closure(borrower_id) = borrower_id, name, address, request_date, loan_amount, repayment_date
最后因为 {loan_amount] --> {repayment_amount} 和 closure(borrower_id) 有 loan_amount,这意味着
closure(borrower_id) = borrower_id, name, address, request_date, loan_amount, repayment_date, repayment_amount
因为 borrower_id 的闭包包含所有属性,borrower_id 是一个键,因为它是最小的,所以它确实是候选键并且唯一的。
现在让我们将模式分解为BCNF。算法是:
Given a schema R.
- Compute keys for R.
Repeat until all relations are in BCNF.
- Pick any R' having a F.D
A --> B
that violates BCNF.- Decompose R' into R1(A,B) and R2(A,Rest of attributes).
- Compute F.D's for R1 and R2.
- Compute keys for R1 and R2.
由于 {request_date} --> {repayment_date, loan_amount} 和 request_date 不是键,它违反了 BCNF,因此我们将模式拆分为两个关系:
R1(请求日期、还款日期、贷款金额)
R2(borrower_id,name,address,request_date,repayment_amount)
显然 R1 在 BCNF 中。但是 R2 在 BCNF 中是 NOT ,因为我们错过了下面的 F.D.这是:
address --> name
而且我们知道地址不是关键,所以我们将 R2 进一步拆分为:
R3(borrower_id,address,request_date,repayment_amount)
R4(地址,姓名)
现在,显然 R3 和 R4 都在 BCNF 中。如果我们不进一步拆分 R2,我们最终会为该人获得的每笔贷款存储相同的地址和姓名组合,这是冗余的。
关于database - 如何将模式规范化为 BCNF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46360396/
我在规范化方面遇到了一些问题。我有一个架构 REPAYMENT,它看起来像这样: 现在,根据我收集到的,架构中的功能依赖项是 {borrower_id} --> {name, address, req
我试图理解 BCNF 和非平凡 FD,但我有点困惑。我目前设计了以下数据库,据我了解这应该是 BCNF。 如果确实如此,您能否提供反馈?请注意,* 表示主键,并且用户不能同时对同一项目出价。一个项目可
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 2 年前。 Improve this qu
我有一个关系看起来像: R = (X,Y,C,D) 和函数依赖: FD = {XY -> CD, YC -> D, D -> X} 我发现候选键是XY、YC、YD。 在这种情况下,我有 3 个候选键.
我正在尝试了解如何规范化数据库,而我们老师给出的练习之一是在 BCNF 中规范化此表: Flight(**CityDeparture,CityArrival,Day**,NationDeparture
我得到以下关系: R(A,B,C,D,E) 以及以下功能依赖项: F1 - AC -> D F2 - D -> E F3 - E -> A 我正在尝试将其转换为 BCNF 格式。 我采取的第一步是找出
设 R 是与模式 R(X,Y,Z) 的关系 它的 FD 是 {XY -> Z, Z -> Y} 我无法将其分解为 BCNF 。 因为r1(Z,Y),r2(Z,X)会失去FD XY -> Z和 R(X,
我无法确定关系何时处于 Boyce-Codd 范式以及如何将其分解为 BCNF 信息(如果不是)。鉴于这个例子: R(A, C, B, D, E) 具有函数依赖关系:A -> B, C -> D 我该
我在理解如何确定关系是否符合 BCNF、3NF 以及如何识别关系的候选键时遇到问题。 考虑关系R = (A, B, C, D) 与函数依赖关系: AB -> C C -> D D -> A 问题包括:
我非常理解BCNF的概念,所以有人给了我这样一种格式的关系 R = {P, Q, S} F = {PQ->S, PS->Q, QS->P} 我可以很容易地说这种关系是 BCNF,因为左侧的所有键也是
我已经设计了一个数据库,现在我在 BCNF 中创建了它,但是我如何确定它确实在 BCNF 中,我如何检查它?我知道什么是 BCNF 但我只想知道是否有任何方法或方法可以检查它或确保它在 BCNF 中。
多值依赖会发生什么?它们是否属于 BCNF 或第四范式等? 最佳答案 4NF 涉及消除多值依赖性。 包括 BCNF 在内的低级范式涉及函数依赖。 维基百科关于范式的文章其实还不错。 4NF BCNF
我一直在寻找将以下关系从其当前状态分解为具有三个函数依赖性的 BCNF。 采纳格言 the key, the whole key, and nothing but the key 我的结论是 B-->
我有以下函数依赖(它们代表了我关系上的所有函数依赖): (1) BrokerName -> Office (2) StockName -> Dividend (3) InvestorId -> Bro
如何判断关系 R 是否属于 BCNF 和 3NF? 我正在阅读一本教科书,它告诉我您正在查看 3 个主要属性,但我无法理解他们在说什么,或者至少在给定时应用他们在说什么关系和 FD。 3个属性:给定具
我有关系 Competitor(PID, EventName, Pname, TeamName, TeamCoach,EventDate, TeamRating). 我有我的FD PID -> Pna
我对 DB BCNF 违规标准的一个特定方面感到困惑。这是一个例子: R(ABCDEF) FD 是 BC->D, C->AF, AB->CE。 我已导出候选键为 AB 和 BC。 考虑到所有 FD 至
我对 DB BCNF 违规标准的一个特定方面感到困惑。这是一个例子: R(ABCDEF) FD 是 BC->D, C->AF, AB->CE。 我已导出候选键为 AB 和 BC。 考虑到所有 FD 至
我作业中出现的一个问题如下: 如果行列式是候选键的一部分,这对于 BCNF 来说是否足够好? 我不这么认为,因为如果所有非键属性都依赖于整个主键,而没有其他属性,那么关系就属于 BCNF。这表示行列式
我正在研究数据库规范化以使其达到最低 3NF,但我无法仅在最后一个中继续。 最后一个表我有以下键。ID、组织编号和名称。 ID 是主键。ID可以决定ORG_NR和Name,ORG_NR也可以决定ID和
我是一名优秀的程序员,十分优秀!