版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、COMP231 Tutorial 2Relational Data ModelRelational AlgebraE-R diagram for a university.titledeptnameiidprerequisitemaincoursecourse_norequirescoursesyllabuscreditstimeroomsection_nosemesteryearcourse- offeringsis offeredenrolsgradenamesidprogramstudentinstructorteachestitleExercise: Convert E-R Diagr
2、am into tablesE-R diagram for a university.titledeptnameiidprerequisitemaincoursecourse_norequirescoursesyllabuscreditstimeroomsection_nosemesteryearcourse- offeringsis offeredenrolsgradenamesidprogramstudentinstructorteachestitleEntities (Not Weak)Tables of Entities (Not Weak)student (sid, name, pr
3、ogram)course (course_no, title, syllabus, credits)instructor (iid, name, dept, title)titledeptnameiidprerequisitemaincoursecourse_norequirescoursesyllabuscreditstimeroomsection_nosemesteryearcourse- offeringsis offeredenrolsgradenamesidprogramstudentinstructorteachestitleE-R diagram for a university
4、.titledeptnameiidprerequisitemaincoursecourse_norequirescoursesyllabuscreditstimeroomsection_nosemesteryearcourse- offeringsis offeredenrolsgradenamesidprogramstudentinstructorteachestitleWeak EntityTable of Weak Entitycourse-offerings (course_no, section_no, year, semester, time, room)titledeptname
5、iidprerequisitemaincoursecourse_norequirescoursesyllabuscreditstimeroomsection_nosemesteryearcourse- offeringsis offeredenrolsgradenamesidprogramstudentinstructorteachestitleE-R diagram for a university.titledeptnameiidprerequisitemaincoursecourse_norequirescoursesyllabuscreditstimeroomsection_nosem
6、esteryearcourse- offeringsis offeredenrolsgradenamesidprogramstudentinstructorteachestitleRelationships (without weak entities)Tables of Relationships (without weak entities)enrols (sid, course_no, section_no, semester, year, grade)teaches (iid, course_no, section_no, semester, year)requires (main_c
7、ourse_no, prerequisite_no)titledeptnameiidprerequisitemaincoursecourse_norequirescoursesyllabuscreditstimeroomsection_nosemesteryearcourse- offeringsis offeredenrolsgradenamesidprogramstudentinstructorteachestitleE-R diagram for a university.titledeptnameiidprerequisitemaincoursecourse_norequirescou
8、rsesyllabuscreditstimeroomsection_nosemesteryearcourse- offeringsis offeredenrolsgradenamesidprogramstudentinstructorteachestitleRelationship with Weak EntityTable of Relationship with Weak EntityThere is no extra table for the relationship between a weak entity and its “owner/strong” entity. The re
9、lationship is already present in the table for the weak entity. course-offerings (courseno, secno, year, semester, time, room)If the relationship between A and B is many-to-oneInclude the key of B into the table of AIf the relationship between A and B is one-to-oneInclude either A or Bs key into the
10、 others tableKeySuperkey Uniquely identify the tuples in the relationCandidate Key (also called key) A minimal superkey (cannot remove any attribute to make it as a superkey)Primary Key A candidate key used in the relation to identify tuplesRelational Algebra - operationsGiven the following tables:
11、employee (person_name, street, city)works (person_name, company_name, salary)company (company_name, city)manages (person_name, manager_name)Select: Find all people who work in “First Bank Corporation”Project: Find all person names that have a job to work.Union: Find every person who is either an emp
12、loyee or a manager (there is automatic duplicate elimination in all algebra operations)Intersection: Find all persons that are both employee and manager.Set Difference: Find all persons that are employee but not manager.Rename: Rename the table employee to employee2Cartesian Product: Produces all po
13、ssible combinations of records from employee and works.Natural Join: Show the employee names, city, and the salary for their jobs (for employees who work in some company).Division: Find all persons that work in all companies.Relational Algebra - operationsemployee (person_name, street, city)works (p
14、erson_name, company_name, salary)company (company_name, city)manages (person_name, manager_name)Select: Find all people who work in “First Bank Corporation”company_name=“First Bank Corporation”(works)Projection: Find all person names that have work.person_name(works)Union: Find every person who is e
15、ither an employee or a manager (there is automatic duplicate elimination in all algebra operations)person_name(employee)manager_name(manages)Intersection: Find all persons that are both employee and manager.person_name(employee)manager_name(manages)Relational Algebra - operationsemployee (person_nam
16、e, street, city)works (person_name, company_name, salary)company (company_name, city)manages (person_name, manager_name)Set difference: Find all persons that are employee but NOT manager.person_name(employee) manager_name(manages)Rename: Rename the table employee to employee2(employee2, employee)Car
17、tesian Product: Produces all possible combinations of records from employee and works.employee worksNatural Join: Show the employee names, city, and the salary for their jobs (for employees who work in some company).person_name, city, salary(employee works)Relational Algebra - operationsemployee (pe
18、rson_name, street, city)works (person_name, company_name, salary)company (company_name, city)manages (person_naame, manager_name)Division: Find all persons that work in ALL companies.(person_name, company_name(works) / (company_name(company)Relational Algebra ExerciseGiven the following tables: empl
19、oyee (person_name, street, city)works (person_name, company_name, salary)company (company_name, city)manages (person_name, manager_name)Find the names of all persons who work for “First Bank Corporation”Find the names and cities of employees who work for “First Bank Corporation”Find the name of all
20、managers who earn more than $10,000Find the worker(s) with highest salary Find the names of employees who do not work for “First Bank Corporation”Find the employees that hold a job in all companies located in Hong KongFind the names of employees who live in the same city and on the same street as th
21、eir managersRelational Algebra Exerciseemployee (person_name, street, city)works (person_name, company_name, salary)company (company_name, city)manages (person_naame, manager_name)Find the names of all persons who work for “First Bank Corporation”person_name (company_name = “First Bank Corporation”
22、(works)Relational Algebra Exerciseemployee (person_name, street, city)works (person_name, company_name, salary)company (company_name, city)manages (person_name, manager_name)Find the names and cities of employees who work for “First Bank Corporation”person_name, city (employee (company_name = “First
23、 Bank Corporation” (works) Relational Algebra Exerciseemployee (person_name, street, city)works (person_name, company_name, salary)company (company_name, city)manages (person_name, manager_name)Find the name of all managers who earn more than $10,000person_name (salary “10000” (works) manager_name (
24、manages)Relational Algebra Exerciseemployee (person_name, street, city)works (person_name, company_name, salary)company (company_name, city)manages (person_name, manager_name)Find the worker(s) with highest salary person_name (works) - w1.person_name ( w1.salaryw2.salary (w1, works) (w2, works)Relational Algebra Exerciseemployee (person_name, street, city)works (person_name, company_name, salary)company (company_name, city)manages (person_name, manager_name)Find the names of employees who do not work for “First Bank Corporation”person_name(employee) -person_name( com
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年北京市公务员招考申论乡村基础设施管护机制模拟试卷及答案
- 2026年北京市公务员招考申论传统手工艺传承创新模拟试卷及答案
- 突发性耳聋的治疗及护理
- 2026年全国新闻记者职业资格考试新闻采编实务试题及答案
- 2026年北京安检证考试题及答案
- 2026年家庭理财规划试题及答案
- 2026年秋季学期统编版小学五年级上册语文教学计划含教学进度表
- 2026年秋季小学道德与法治五年级上册(新教材)教学计划
- 2026年园艺综合(园艺综合知识)试题及答案
- 电子陶瓷料制配工成果竞赛考核试卷含答案
- 2026年非融资担保服务行业市场深度调查及投资规划报告及未来五至十年区域市场差异与机会
- 2026年秋季部编版九年级上册《道德与法治》主要知识点
- 自动化装置验收流程及标准
- 2026年秋统编版(新)小学道德与法治一年级上册《平平安安回家来》课时练习及答案
- 2026年上半年落实全面从严主体责任情况报告
- 2025年黑龙江省辅警招聘笔试题库及答案解析
- 课后服务外聘机构管理制度(3篇)
- 中专学校实习学生管理工作总结范文
- 河北省石家庄市等2地2025-2026学年高二上学期10月月考物理试题
- 猪场非瘟质保协议书
- 四季的星空课件
评论
0/150
提交评论