版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、COMP231 RevisionPrepared by Raymond WongCOMP2311Revision1. ER DiagramPhase 1 and Phase 3ER-diagram, Relation and proof of the 3rd normal formE.g. Student takes a courseStudentStudent ID UniqueStudent NameCourseCourse ID UniqueCourse NameStudentStudent IDStudent NameCourseCourse IDCourse NameCOMP2312
2、Revision1. ER DiagramE.g. Student takes a courseStudentStudent IDStudent NameCourseCourse IDCourse NameTakeAssumption:Each student takes at least one courseEach course is taken by at least one studentSchemaStudentCourseTake(Student ID, Student Name)(Course ID, Course Name)(Student ID, Course ID)Phas
3、e 1 and Phase 3ER-diagram, Relation and proof of the 3rd normal formCOMP2313Revision1. ER DiagramE.g. Student takes a courseAssumption:Student ID is unique Student ID can uniquely identify a studentCourse ID is unique Course ID can uniquely identify a courseSchemaStudentCourseTake(Student ID, Studen
4、t Name)(Course ID, Course Name)(Student ID, Course ID)Non-trivial Functional DependencyStudent ID Student NameCourse ID Course NameCOMP2314Revision1. ER DiagramSchemaStudentCourseTake(Student ID, Student Name)(Course ID, Course Name)(Student ID, Course ID)Non-trivial Functional DependencyStudent ID
5、Student NameCourse ID Course NameProof of 3NFR is in 3NF if for any A in F A is trivial (A ), or contains a key for R, orA is part of some key(s) for RSchema Student is in 3NFBecausefor Student ID Student Name,Student ID is a key of StudentSchema Course is in 3NFBecausefor Course ID Course Name,Cour
6、se ID is a key of CourseSchema Take is in 3NFBecauseany functional dependencies for Relation Take are trivial.COMP2315Revision2. Relational Algebra/SQLQuery 1: Find the name of all students who take the course taught by “Prof. Wong” studentcoursetakesidsnamecidnamecnameteacherstudent (sid, sname)cou
7、rse (cid, cname, teacher)take (sid, cid)Query 2: Find the name of all students who take ALL courses taught by “Prof. Wong” COMP2316Revision2. Relational Algebra/SQLQuery 1: Find the name of all students who take the course taught by “Prof. Wong” studentcoursetakesidsnamecidnamecnameteacherstudent (s
8、id, sname)course (cid, cname, teacher)take (sid, cid)select S.snamefrom student S, take T, course Cwhere S.sid = T.sid and T.cid = C.cid and C.teacher = Prof. Wongsname ( )teacher=Prof. Wong(course)student takeCourses taught by Prof. WongStudents who take courses taught by Prof. WongRelationalAlgebr
9、aSQLCOMP2317Revision2. Relational Algebra/SQLQuery 2: Find the name of all students who take ALL courses taught by “Prof. Wong” studentcoursetakesidsnamecidnamecnameteacherstudent (sid, sname)course (cid, cname, teacher)take (sid, cid)snameteacher=Prof. Wong(course)(student )Courses taught by Prof.
10、WongA set of cid of courses taught by Prof. WongRelationalAlgebracid ( )set_of_cid A set of sid (of students) who take all courses taught by Prof. Wong(take / set_of cid)Get back snameresult COMP2318Revision2. Relational Algebra/SQLstudentcoursetakesidsnamecidnamecnameteachere.g.1 231537Prof. Wong t
11、eaches 231251252271Peter takesPeter takes only ONE course taught by Prof. Wong Peter DOES NOT take ALL courses taught by Prof. Wong 231537Prof. Wong teaches 231251252271Raymond takes537Raymond takes TWO courses taught by Prof. Wong Raymond TAKES ALL courses taught by Prof. Wong e.g.2COMP2319Revision
12、2. Relational Algebra/SQLe.g.1 231537Prof. Wong teaches 231251252271Peter takesPeter DOES NOT take ALL courses taught by Prof. Wong 231537Prof. Wong teaches 231251252271Raymond takes537Raymond TAKES ALL courses taught by Prof. Wong e.g.2=537Exist?Yes=Exist?NoConclusionA set of courses taught by Prof
13、. WongA set of courses taken by RaymondCourses taughtby Prof. WongCourses takenby a student=Resultif exist = yes, the student DOES NOT take ALL courses taught by Prof. WongIf exist = no, the student takes ALL courses taught by Prof. Wong COMP23110Revision2. Relational Algebra/SQLConclusionCourses ta
14、ughtby Prof. WongCourses takenby a student=ResultQuery 2: Find the name of all students who take ALL courses taught by “Prof. Wong” if exist = yes, the student DOES NOT take ALL courses taught by Prof. WongIf exist = no, the student takes ALL courses taught by Prof. Wong calculateCourses taughtby Pr
15、of. WongCourses takenby student S=ResultFor each student S,If exist = no, the student takes ALL courses taught by Prof. Wong (i.e “not exists” in SQL)COMP23111Revision Query 2: Find the name of all students who take ALL courses taught by “Prof. Wong” calculateCourses taughtby Prof. WongCourses taken
16、by student S=ResultFor each student S,If exist = no, the student takes ALL courses taught by Prof. Wong (i.e “not exists” in SQL)select S.snamefrom student Swhere not existsstudent (sid, sname)course (cid, cname, teacher)take (sid, cid)( select C.cid from course C where teacher = Prof. Wong) ( selec
17、t T.cid from take T where T.sid = S.sid)Courses taught by Prof. Wong Courses taken by student S ( except )SQLCOMP23112RevisionQuery 1: Find the name of all students who take the course taught by “Prof. Wong” select S.snamefrom student S, take T, course Cwhere S.sid = T.sid and T.cid = C.cid and C.te
18、acher = Prof. Wongsname ( )teacher=Prof. Wong(course)student takeRelationalAlgebraSQLQuery 2: Find the name of all students who take ALL courses taught by “Prof. Wong” snameteacher=Prof. Wong(course)(student )cid ( )set_of_cid (take / set_of cid)result RelationalAlgebraSQLselect S.snamefrom student
19、Swhere not exists( select C.cid from course C where teacher = Prof. Wong) ( select T.cid from take T where T.sid = S.sid) ( except )One of the courses taught by Prof. WongAll courses taught by Prof. WongNatural JoinNatural JoinDivisionNot exists(Except)COMP23113Revision2. Relational Algebra/SQLQuery
20、 3: Find the cid of all courses of class size 10studentcoursetakesidsnamecidnamecnameteacherstudent (sid, sname)course (cid, cname, teacher)take (sid, cid)Query 4: Find the cid and cname of all courses of class size 10COMP23114Revision2. Relational Algebra/SQLQuery 3: Find the cid of all courses of class size 10studentcoursetakesidsnamecidnamecnameteacherstudent (sid, sname)course (cid, cname, teacher)take (sid, cid)select T.cidfrom take Tgroup by T.
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 企业工作个人表扬信
- 人员计划书范文
- DB12T 579-2015 焊接绝热气瓶定期检验与评定
- 中班家长半日活动小结
- 小班洗澡课件教学课件
- 影响农业生产的主要区位因素
- 绿色产品评价 水泥 征求意见稿
- 镜子动漫课件教学课件
- 八年级上学期语文9月月考试卷-2
- 宇航化工突发 环境应急预案
- 工业机器人系统运维知识竞赛题库及答案(100题)
- 智慧农贸市场解决方案
- 徐州市2023-2024学年九年级上学期期末道德与法治试卷(含答案解析)
- 北师大版二年级上册100以内加减法混合运算大全500题及答案
- 多源数据融合车辆定位系统
- 质量管理五大工具之培训课件
- 销售到营销的转变
- 骨质疏松患者的护理干预与教育
- 述职报告 设备主管述职报告
- 西部地区中等职业教育发展的现状与对策-以麻江县为例的中期报告
- 中职幼儿保育职业生涯规划书
评论
0/150
提交评论