版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 制度培训演讲串词
- 手术AI在老年骨科手术中的应用
- 2026年杭州市中小学生绿色低碳环保知识竞赛试题(含答案)八年级上学期
- 危险品车队安全生产监督检查制度(2篇)
- 演员排练方案规范
- 慢病防控中的健康传播策略
- 慢病管理中社会支持网络构建
- 军工安全培训平台课件
- 感染高风险环节纠纷干预策略的实践探索
- 贷款合同协议书
- 展馆人流方案模板
- 128个护理诊断及措施
- 冬季高速公路安全培训
- 感应加热器安全操作规程
- 音乐与乐器的声学原理
- 《网络与信息安全管理员》三级考试题库(含答案)-20230926094641
- 内镜室医生护士职责
- 2023年新高考I卷英语试题讲评课件-2024届高考英语一轮复习
- 提高铝模板施工质量合格率
- MT/T 106-1996顺槽用刮板转载机通用技术条件
- GB/T 6672-2001塑料薄膜和薄片厚度测定机械测量法
评论
0/150
提交评论