版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 化工企业如何高质量开展隐患排查治理课件
- 2026年堤防巡堤查险员(技师)职业技能等级认定真题汇编
- 2026年桥面伸缩缝修补工(高级技师)职业技能等级认定模拟试题
- 2027 山东综评系统(原云平台)【艺术素养美育】书画展参展登记说明模板20篇
- 数学冲刺模拟卷(十)讲题课件
- 浙教版数学七年级下册 第4章 因式分解 单元检测A卷·夯实基础 试卷 含答案
- 2026年职业健康职业病危害鉴定知识考察模拟试题及参考答案
- 2026年业务经理转正模拟试题及参考答案
- 2026年新冠重症救治培训模拟试题及参考答案
- 2026年中职农村电商模拟试题及参考答案
- 广东上进2027届高三联考11月供题训练英语试卷(含答案)
- 高中物理力学实验牛顿第二定律验证解题步骤规范强化训练试卷及答案
- 中储粮招聘笔试试题及详细答案
- 2026年全国大学生525心理知识竞赛题库及答案
- 小学三年级劳动课水培大蒜种植活动教学设计
- 2026-2027学年教科版五年级上册科学第三单元《运动和力》单元素养测评卷含答案
- 2026-2027学年九年级数学上学期 期末测试卷(人教版)
- 公立医院科研项目管理制度
- 知道智慧树《汽车技术战略与产业政策(长安大学)》网课章节测试答案
- 丝印网版管理办法
- 2025年中石化违纪违规心得(3篇)
评论
0/150
提交评论