tutorial1 ER Diagrams.ppt_第1页
tutorial1 ER Diagrams.ppt_第2页
tutorial1 ER Diagrams.ppt_第3页
tutorial1 ER Diagrams.ppt_第4页
tutorial1 ER Diagrams.ppt_第5页
已阅读5页,还剩25页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、COMP231 Tutorial 1,ER Diagrams,About Me,PENG Yu, Grace gracepyust.hk Office hour: TBA Office: 4212,E-R Diagram,Rectangle entity set Ellipse attribute Diamond relationship set Double ellipse multivalued attribute Dashed ellipse derived attribute Double line total participation Double rectangle weak e

2、ntity set Double diamond relationship set for weak entity set,Exercise 1,A university registrars office maintains data about the following entities: course, including number, title, credits, syllabus, and prerequisites; course offering, including course number, year, semester, section number, instru

3、ctor(s), timings, and classroom; student, including student-id, name, and program; instructor, including identification number, name, department, and title. Further, the enrollment of students in courses and grades awarded to students in each course they are enrolled for must be appropriately modele

4、d. Construct an E-R diagram for the registrars office. Document all assumptions that you make about the cardinality constraints and participation constraints.,Entity sets,“A university registrars office maintains data about the following entity sets:” (a) course (b) course offering (c) student (d) i

5、nstructor,course,course-offering,student,instructor,Course,“course including number, title, credits, syllabus, and prerequisites” Entity set? Attribute? Relationship set? Roles? Cardinality constraint? Participation constraint?,prerequisite,maincourse,course_no,title,requires,course,syllabus,credits

6、,“course offering, including course number, year, semester, section number, instructor(s), timings, and classroom”,Course Offering,time,room,course,section_no,semester,year,course- offering,is offered,course_no,Weak Entity Set,A weak entity set can be identified uniquely only by considering the prim

7、ary key of another (owner) entity set Owner entity set and weak entity set must participate in one-to-many relationship set (one owner, many weak entities). Weak entity set must have total participation in this identifying relationship set. Difference between weak entity and existence dependency WE

8、implies ED but not the other way round. WE has only a partial key but ED may have a primary key,A,B,A,B,A,Student, Instructor,“student, including student-id, name, and program” “instructor, including identification number, name, department, and title”,student,name,sid,program,instructor,title,dept,n

9、ame,iid,Enrollment,“Further, the enrollment of students in courses and grades awarded to students in each course they are enrolled for must be appropriately modeled.”,student,course-offering,enrols,grade,Exercise 1,A university registrars office maintains data about the following entities: course, i

10、ncluding number, title, credits, syllabus, and prerequisites; course offering, including course number, year, semester, section number, instructor(s), timings, and classroom; student, including student-id, name, and program; instructor, including identification number, name, department, and title. F

11、urther, the enrollment of students in courses and grades awarded to students in each course they are enrolled for must be appropriately modeled. Construct an E-R diagram for the registrars office. Document all assumptions that you make about the cardinality constraints and participation constraints.

12、,Anymore ?,Instructor teaches course.,instructor,teaches,course-offering,A course-offering does not have to have an instructor.,A course-offering has to have an instructor.,Partial participation,Total participation,title,dept,name,iid,Figure 1 E-R diagram for a university registrar office.,prerequis

13、ite,maincourse,course_no,course,syllabus,credits,time,room,section_no,semester,year,enrolls,grade,name,sid,program,student,instructor,teaches,title,requires,More ,Based on Figure 1 , modify the E-R Diagram so as to present the following information. Each instructor must belong to exactly one departm

14、ent. Each department includes dept-id, name, telephone number. Each department must have at least one instructor.,Department,Each instructor must belong to exactly one department Each department must have a least one instructor.,instructor,department,belongs,telephone number,dept-id,name,Exercise 2,

15、Design a database to organize the information about a factory and the products that are manufactured there. The relevant information is as follows: The factory has a number of employees. For each employee you need to store the name, employee number, and salary. Each employee must be an administrativ

16、e staff or a worker, but not both. Administrative employees must take seminars. For each seminar we keep its id, name and date. For the administrative staff, you must store the grade received, for each seminar taken. The factory manufactures a number of products and each product is identified by a p

17、roduct id and has a name. A worker is assigned to work on exactly one product; a product has multiple (one or more) workers assigned to it. A large number of items are manufactured for each product. Each item has a serial number and a color. Different items of the same product have different serial

18、numbers. However, two items that belong to different products may have the same serial number.,Exercise 2,Design a database to organize the information about a factory and the products that are manufactured there. The relevant information is as follows: The factory has a number of employees. For eac

19、h employee you need to store the name, employee number, and salary. Each employee must be an administrative staff or a worker, but not both. Administrative employees must take seminars. For each seminar we keep its id, name and date. For the administrative staff, you must store the grade received, f

20、or each seminar taken. The factory manufactures a number of products and each product is identified by a product id and has a name. A worker is assigned to work on exactly one product; a product has multiple (one or more) workers assigned to it. A large number of items are manufactured for each prod

21、uct. Each item has a serial number and a color. Different items of the same product have different serial numbers. However, two items that belong to different products may have the same serial number.,Employee, Administrative staff, Worker,The factory has a number of employees. For each employee you

22、 need to store the name, employee number, and salary. Each employee must be an administrative staff or a worker, but not both.,ISA,Employee,Administrative staff,Worker,Seminar,Administrative employees must take seminars. For each seminar we keep its id, name and date. For the administrative staff, y

23、ou must store the grade received, for each seminar taken.,Administrative staff,Takes,Seminar,Product,The factory manufactures a number of products and each product is identified by a product id and has a name. A worker is assigned to work on exactly one product; a product has multiple (one or more)

24、workers assigned to it.,Worker,Works for,Product,Item,A large number of items are manufactured for each product. Each item has a serial number and a color. Different items of the same product have different serial numbers. However, two items that belong to different products may have the same serial

25、 number.,Item,Product,ISA,Employee,Administrative staff,Worker,Takes,Seminar,Works for,Product,Item,Conclusion,Notations of E-R Diagram Generally, we construct an E-R diagram, by identifying: Entity sets What should be entities? Strong or weak entity set? Relationship sets Need to label roles? Attri

26、butes Can be inherited? (generalization or specification) Participation constraints: Total participation or partial participation? Cardinality constraints One to one, one to many or many to many?,or,or,Q&A,Example,We want to create database for a bank in which we store: Customers (id, name, city). A

27、ccounts (number, balance) Loans (number, amount) Branches (name, city, assets) Each customer can have any number of accounts and loans Each account and loan is associated with one branch. A customer must have either one account or loan in order to be in the database The balance in each account shoul

28、d be $100. The last two constraints cannot be expressed by the ER diagram.,Solution,Participation constraint,Cardinality constraint,Example,We want to create a very simple database for SCUT in which to record information about professors, students and classes. For each professor we need to store the HK-id, name and office number. For each student we need to store the student-id and name For each class the id (e.g., COMP 231) and the name. Each class is taught by exactly one professor. Each student must take at least one class. For

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论