传递依赖有什么问题? [英] What is wrong with a transitive dependency?

查看:424
本文介绍了传递依赖有什么问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的数据库设计中有一些传递依赖。我被上司告诉这些可能会导致错误。我发现很难找到资源,将告诉我如何有这些依赖将导致错误。他们会导致什么样的问题?

I have some transitive dependencies in my database design. I have been told by my superiors that these can cause bugs. I am finding it difficult to find resources that will tell me how having these dependencies will cause bugs. What kind of problems will they cause?

我不是在争论这个事实,只是渴望了解他们可能导致什么样的问题。

I am not disputing the fact, just eager to learn what kind of problems they can cause.

感谢。

编辑更多详细信息:

来自wikipedia:

From wikipedia :

传递依赖关系
传递依赖关系是一种间接函数依赖关系,其中X→Z仅凭借X→Y和Y→Z。

Transitive dependency A transitive dependency is an indirect functional dependency, one in which X→Z only by virtue of X→Y and Y→Z.

推荐答案

我将通过一个示例解释:

I'll explain by an example:

-------------------------------------------------------------------
|  Course  |    Field     |   Instructor   |  Instructor Phone    |
-------------------------------------------------------------------
|  English |  Languages   |  John Doe      |     0123456789       |
|  French  |  Languages   |  John Doe      |     0123456789       |
|  Drawing |  Art         |  Alan Smith    |     9856321158       |
|  PHP     |  Programming |  Camella Ford  |     2225558887       |
|  C++     |  Programming |  Camella Ford  |     2225558887       |
-------------------------------------------------------------------




  • 如果您有课程,您可以轻松地获得教师课程 - >教师

  • 如果您有教师 c $>
  • 如果您有教师您可以轻松取得电话 Instructor->电话

    • If you have a Course you can easily get its Instructor so Course ->Instructor.
    • If you have an Instructor you can't get its Course as he might be teaching different courses.
    • If you have an Instructor you can easily get his Phone so Instructor->Phone.
    • 这意味着如果你有一个课程,那么你可以得到教师电话这意味着课程 - >教师电话(即传递依赖)

      That means the if you have a Course then you can get the Instructor Phone which means Course ->Instructor Phone (i.e. Transitive dependency)

      / p>

      Now for the problems:


      1. 如果您同时删除法语 code>课程,那么你将删除他们的教师 John Doe ,他的电话号码将永远丢失。

      2. 无法向您的数据库添加新的教师,除非您先为他添加课程,或者您可以复制 c $> 教师中的数据更糟。

      3. 如果教师 John Doe 更改他的电话号码,那么你将不得不更新他教授的所有课程与新的信息,这很容易犯错误。

      4. 您不能从数据库中删除教师

      5. 如果您决定保留教师的出生日期,该怎么办?如果您删除了所有课程,或者将所有课程设置为空。您必须在 Courses 表中添加生日字段。这是否听起来合乎逻辑?为什么要在课程表中保留教师信息。

      1. If you delete both the French and English courses then you will delete their instructor John Doe as well and his phone number will be lost forever.
      2. There is no way to add a new Instructor to your database unless you add a Course for him first, or you can duplicate the data in an Instructors table which is even worse.
      3. If Instructor John Doe changes his phone number then you will have to update all Courses that he teaches with the new info which can be very prone to mistakes.
      4. You can't delete an Instructor from your database unless you delete all the courses he teaches or set all his fields to null.
      5. What if you decide to keep the birth date of your instructors? You will have to add a Birth Date field to the Courses table. Does this even sound logical? Why keep an instructor information in the courses table in the first place.

      这篇关于传递依赖有什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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