lecture 4 e-r model

21
Lecture 4: E-R Diagrams  Instructor:Haya Sammaneh

Upload: syeda-sana-mahmood

Post on 11-Oct-2015

9 views

Category:

Documents


0 download

DESCRIPTION

ER Model

TRANSCRIPT

  • Lecture 4: E-R Diagrams

    Instructor:Haya Sammaneh

  • E-R DiagramRectangle entityEllipse attributeDiamond relationshipDouble ellipse multi-valued attributeDashed ellipse derived attributeDouble line total participation (existence dependency)Double rectangle weak entityDouble diamond relationships for weak entity

  • Composite attribute: consists of several componentsCountryEmployeeAddressStreetCityEmpNoName

  • Existence DependenceThe existence of an entity depends on the existence of another entity

    CustomerLoanloanborrowCusNoLoanNo

  • Weak EntitiesA weak entity cannot be identified with its own attributes no keyA weak entity implies existence dependency but NOT vice versa

  • LoanNoAmountDate_payPaymentNoPaymentA loan may have 240 payments, each identified by a payment no 1 - 240.The PaymentNo is unique given a particular loan but not unique globally PaymentNo is called partial key The primary key of Payment is the combination of LoanNo and PaymentNo.LoanpaymentAmountLoan

  • Ternary Relationship

  • ExerciseA university registrars office maintains data about the following entities: courses, including number, title, credits, syllabus, and prerequisites; course offerings, including course number, year, semester, section number, instructor(s), timings, and classroom; students, including student-id, name, and program;instructors, including identification number, name, department, and title. The enrollment of students in courses and grades awarded to students in each course they are enrolledConstruct an E-R diagram for the registrars office.

  • EntitiesA university registrars office maintains data about the following entities:

    (a) courses (b) course offerings (c) students (d) instructorscoursecourse-offeringsstudentinstructor

  • Coursecourses including number, title, credits, syllabus, and prerequisitesAttribute?Relationship?

    prerequisitemaincoursecourse_notitlerequirescoursesyllabuscredits

  • course offerings, including course number, year, semester, section number, instructor(s), timings, and classroomCourse Offeringtimeroomcoursesection_nosemesteryearcourse- offeringsis offeredcourse_no

  • Weak EntityA weak entity can be identified uniquely only by considering the primary key of another (owner) entityOwner entity set and weak entity set must participate in one-to-many relationships (one owner, many weak entities).Weak entity set must have total participation in th identifying relationship set. Difference between weak entity (WE)and existence dependency(ED)WE implies ED but not the other way round. WE has only a partial key but ED may have a primary key ABA

  • Student, Instructorstudents, including student-id, name, and programinstructors, including identification number, name, department, and titlestudentnamesidprograminstructortitledeptnameiid

  • EnrollmentThe enrollment of students in courses and grades awarded to students in each course they are enrolledstudentcourse- offeringsenrolsgrade

  • Anymore ?Instructor teach course..instructorteachescourse- offerings

  • titledeptnameiidE-R diagram for a university.prerequisitemaincoursecourse_norequirescoursesyllabuscreditstimeroomsection_nosemesteryearenrolsgradenamesidprogramstudentinstructorteachestitle

  • Exercise Consider a database that records the grades of students in different exams of different course offerings.assume that course offerings include time, room; and can be identified uniquely by course_no, semester, year, section_no.students, including student-id, name, and program;exam, including eid (optional), name, place, time.Furthermore, grades of students in different exams of course offerings must be modeled.Construct an E-R diagram that models exams as entities, and uses a ternary relationship, for the above database.

  • E-R diagram for marks database.studentsidprogramcourse-offeringsyearsemestertimeroomsection_notakesgradeexameidnameplacetimecourse_noname

  • ExerciseConstruct an alternative E-R diagram that uses only a binary relationship between students and course-offerings. Make sure that only one relationship exists between a particular student and course-offering pair, yet you can represent the marks that a student gets in different exams of a course offering.

  • semesterroomnameAnother E-R diagram for marks database.marksstudentcourse-offeringsexamoftakessection_noyearexamplacetimegradesidnamecourse_notimeprogram

  • E-R Diagram for a Banking Enterprise

    **multivalued attribute: e.g. one can have zero, one, or several phone numbersderived attribute: e.g. age can be derived from birthday and current date. *Mapping constraints: e.g. one to many, or one to one.***********