写函数依赖 [英] Writing the functional dependency

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

问题描述

第一个模块是用户模块。管理员,学生,讲师或访客是从系统中受益的用户,他们参加此模块。管理员将为每个用户分配角色作为学生或讲师。每个角色有不同的权限,讲师可以上传作业和课程材料,创建在线测验和单个上传文件。用户具有用户ID,注册日期,最近登录日期,登录帐户,密码,名字,姓氏和其他需要的信息。只要说学生ID和讲师ID不能是主键。因此,当作业ID和测验ID是主键时,我如何声明作业或测验ID在功能上取决于讲师?基于我的功能依赖,我不确定我如何将它们与函数依赖关联?

 实体: 
用户(用户ID,学生ID,讲师ID,来宾ID,课程ID,作业ID,测验ID,文件上传,注册日期,最近登录日期,登录帐户,密码,电子邮件,出生日期)

功能依赖性
用户ID - > {学生ID,讲师ID,访客ID,注册日期,最近登录日期,登录帐户,密码,名字,姓,电子邮件,出生日期}
讲师ID - {课程ID,作业ID,测验ID,文件上传}

完全依赖
用户ID,讲师ID - > {学生ID,客人ID,课程ID,作业ID,测验ID,文件上传,注册日期,最近登录日期,登录帐户,密码,名字,姓氏,电子邮件,出生日期}


解决方案

目前尚不清楚您要完成的工作。



首先我们确定我们感兴趣的应用程序关系,例如user [userID]具有角色讲师或用户[用户ID]具有名字[名字]和密码[密码]和...。



对于每个关系,其应用程序关系的含义为每一列确定了哪些列是功能依赖。然后我们找到一个最小的封面。这确定候选键。我们可以选择一个候选键作为主键。



这确定每个候选键上的非素数列的完全和部分依赖性。这允许我们通过分解我们的关系将候选键上的非素数列部分函数depencies分成单独的关系,从而规范化为2NF。


只要说学生ID和讲师ID不能是主键。
因此,当作业ID和测验ID
是主键时,我如何声明作业或测验ID是
在功能上取决于讲师?


这没有意义。我们不能确定候选键,直到我们确定所有的功能依赖。另外:您的意思是{studentID,lecturerID}不能是主键,还是您的意思是{student ID}不能和{lecturer ID}不能?另外:can not是什么意思?



我们说assignmentID和quizID在功能上取决于lecturerID在某些关系中:

  {lecturer ID}  - > {assignment ID} 
{lecturer ID} - > {quiz ID}

我们可以将右侧(确定的列集) set(determiner):

  {lecturer ID}  - > {assignment ID,quiz ID} 

但是还有其他的规则,基于我的函数依赖,我不确定我如何
假设将它们与函数依赖关联?


这没有意义。



如果User的唯一功能依赖是Functional dependencies的传递闭包中的依赖,那么只有FD那么最小覆盖是

  {user ID}  - > {学生ID,讲师ID,访客ID,课程ID,作业ID,测验ID,文件上传,注册日期,最近登录日期,登录帐户,密码,名字,姓氏,电子邮件, $ b  

,唯一的候选键为

  {user ID} 

且没有非首栏部分依赖对候选键。


First module is User module. Administrators, students, lecturers or guests are users who benefit from the system and they take part in this module. Administrator will assign role as student or lecturer for each user. Each role has different privileges that is lecturer can upload the assignment and course materials, create the online quiz and single upload file. Users have information such as user ID, date of registration, date of latest logon, login account, password, first name, last name, and others details needed. Just say that student ID and lecturer ID cannot be the primary key. Therefore, how am I suppose to state that assignment or quiz ID is functionally dependent on lecturer when assignment ID and my quiz ID is a primary key? Based on my functional dependency, I'm not really sure how am I suppose to relate them to functional dependency?

Entity: User
User(user ID, student ID,  lecturer ID, guest ID, course ID, assignment ID, quiz ID, file upload, date of registration, date of latest logon, login account, password, first name, last name, e-mail, birthdate)

Functional dependency
user ID -> {student ID, lecturer ID, guest ID, date of registration, date of latest logon, login account, password, first name, last name, e-mail, birthdate}
lecturer ID -> {course ID, assignment ID, quiz ID, file upload}

Full dependency
user ID, lecturer ID -> {student ID, guest ID, course ID, assignment ID, quiz ID, file upload, date of registration, date of latest logon, login account, password, first name, last name, e-mail, birthdate}

解决方案

It is not clear what you are trying to accomplish. And you don't seem to understand the steps that we go through in schema design.

First we determine what application relationships we are interested in. Eg "user [userID] has role lecturer" or "user [user ID] has first name [first name] and password [password] and ...". Each gets a base relation that holds the rows of values that are related that way.

For each relation the meaning of its application relationship determines for every column what sets of columns it is functionally dependent on. Then we find a minimal cover for that. This determines candidate keys. We can pick one candidate key as primary key.

This determines full and partial dependencies of non-prime columns on each candidate key. This allows us to normalize to 2NF by decomposing our relation to separate the non-prime column partial functional depencies on candidate keys into separate relations.

Just say that student ID and lecturer ID cannot be the primary key. Therefore, how am I suppose to state that assignment or quiz ID is functionally dependent on lecturer when assignment ID and my quiz ID is a primary key?

This doesn't make sense. We can't determine the candidate keys until we determine all the functional dependencies. Also: Do you mean {studentID,lecturerID} "can't be the primary key", or do you mean {student ID} "can't" and {lecturer ID} "can't"? Also: What do you mean by "can't"?

We say assignmentID and quizID are functionally dependent on lecturerID in some relation by:

 {lecturer ID} -> {assignment ID}
 {lecturer ID} -> {quiz ID}

We can combine right hand sides (determined column sets) with the same left hand side set (determiner):

{lecturer ID} -> {assignment ID, quiz ID}

But there other rules like that for finding a minimal cover.

Based on my functional dependency, I'm not really sure how am I suppose to relate them to functional dependency?

This doesn't make sense. Relate what to your functional dependencies?

If the only functional dependencies for "User" are the ones in the transitive closure of "Functional dependencies" (ie the only FDs are the ones that must be there when those ones are) then a minimal cover is

{user ID} -> {student ID,  lecturer ID, guest ID, course ID, assignment ID, quiz ID, file upload, date of registration, date of latest logon, login account, password, first name, last name, e-mail, birthdate}

and the only candidate key is

{user ID}

and there are no non-prime column partial dependencies on a candidate key.

这篇关于写函数依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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