版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 中国羊驼绒制品行业市场现状分析及竞争格局与投资发展研究报告2024-2029版
- 中国商务外包行业调研分析及发展趋势预测研究报告2024-2029版
- 中国环保书籍行业供需趋势及投资风险研究报告2024-2029版
- 中国调色机市场发展分析及市场趋势与投资方向研究报告2024-2029版
- 中国车镜行业发展分析及投资前景预测研究报告2024-2029版
- 中国蹦极用品行业发展分析及发展前景与趋势预测研究报告2024-2029版
- 2024年碳酸甲乙酯合作协议书
- 2024年石棉增强塑料项目合作计划书
- 《2024年 毕业献礼画展活动方案策划》范文
- 《2024年 学前教育回归生活课程研究》范文
- 心理游戏在初中思想品德课中的应用策略分析
- 2021年中考道德与法治试卷分析
- 机场AOC-坐席协作控制系统应用说明
- 施工单位项目管理人员考勤表
- 最新数控卧式带锯床技术参数
- 说课-Lesson6-Maddy's-familyPPT优秀课件
- 影视制作报价表
- LH160使用说明书090708
- 项目安全生产管理体系(完整版)
- 文泰雕刻软件路径的做法及雕刻文件的保存方法
- 蓝油烃关键技术研究建设项目建议书写作模板
评论
0/150
提交评论