COMP231 Tutorial 1 ER Model and ER to Relational Schema.

22
COMP231 Tutorial 1 COMP231 Tutorial 1 ER Model and ER to Relational Schema

Transcript of COMP231 Tutorial 1 ER Model and ER to Relational Schema.

Page 1: COMP231 Tutorial 1 ER Model and ER to Relational Schema.

COMP231 Tutorial 1COMP231 Tutorial 1

ER Model and ER to Relational Schema

Page 2: COMP231 Tutorial 1 ER Model and ER to Relational Schema.

Fall 20062Database Management Systems

E-R DiagramE-R Diagram

Rectangles – entity sets

Ellipses – attributes

Diamonds – relationship sets

Double ellipses – multivalued attributes

Dashed ellipses – derived attributes

Double lines – total participation

Double rectangles – weak entity sets

Double diamonds – identifying relationship sets

Page 3: COMP231 Tutorial 1 ER Model and ER to Relational Schema.

Fall 20063Database Management Systems

Exercise 1.1 Construct E-R DiagramExercise 1.1 Construct E-R Diagram

A university registrar’s 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.

Further, the enrollment of students in courses and grades awarded to students in each course they are enrolled must be appropriately modeled.

Construct an E-R diagram for the registrar’s office.

Page 4: COMP231 Tutorial 1 ER Model and ER to Relational Schema.

Fall 20064Database Management Systems

EntitiesEntities

course

course-offeringstudent instructor

Page 5: COMP231 Tutorial 1 ER Model and ER to Relational Schema.

Fall 20065Database Management Systems

CourseCourse

“ courses including number, title, credits, syllabus, and prerequisites”

Attribute?

Relationship?

course

courseno

title

credits

syllabusrequires

prerequisite

maincourse

Page 6: COMP231 Tutorial 1 ER Model and ER to Relational Schema.

Fall 20066Database Management Systems

Course OfferingCourse Offering

“ course offerings, including course number, year, semester, section number, instructor(s), timings, and classroom”

course- offering

year

semestertime

room

secno

courseis_offered

courseno

Page 7: COMP231 Tutorial 1 ER Model and ER to Relational Schema.

Fall 20067Database Management Systems

Weak EntityWeak Entity

A weak entity can only be identified uniquely by combining the primary key of another (owner) entity and the partial key of itself.

Owner entity set and weak entity set must participate in one-to-many relationship (one owner entity, many weak entities).

Weak entity set must have total participation in this identifying relationship set.

Page 8: COMP231 Tutorial 1 ER Model and ER to Relational Schema.

Fall 20068Database Management Systems

Student, InstructorStudent, Instructor

“ students, including student-id, name, and program”

“instructors, including identification number, name, department, and title”

student

namesid

program

instructor

titledept

nameiid

Page 9: COMP231 Tutorial 1 ER Model and ER to Relational Schema.

Fall 20069Database Management Systems

EnrollmentEnrollment

“ Further, the enrollment of students in courses and grades awarded to students in each course they are enrolled must be appropriately modeled.”

student course-offeringenrolls

grade

Page 10: COMP231 Tutorial 1 ER Model and ER to Relational Schema.

Fall 200610Database Management Systems

Anymore??Anymore??

Instructor teaches course…..

course-offering

instructorteache

s

Page 11: COMP231 Tutorial 1 ER Model and ER to Relational Schema.

Fall 200611Database Management Systems

E-R Diagram for a UniversityE-R Diagram for a University

Page 12: COMP231 Tutorial 1 ER Model and ER to Relational Schema.

Fall 200612Database Management Systems

Exercise 1.2 Covert E-R Diagram into TablesExercise 1.2 Covert E-R Diagram into Tables

Page 13: COMP231 Tutorial 1 ER Model and ER to Relational Schema.

Fall 200613Database Management Systems

Entities (Not Weak)Entities (Not Weak)

Page 14: COMP231 Tutorial 1 ER Model and ER to Relational Schema.

Fall 200614Database Management Systems

Entities (Not Weak)Entities (Not Weak)

course (courseno, title, syllabus, credits)

student (sid, name, program)

instructor (iid, name, dept, title)

Page 15: COMP231 Tutorial 1 ER Model and ER to Relational Schema.

Fall 200615Database Management Systems

Weak EntitiesWeak Entities

Page 16: COMP231 Tutorial 1 ER Model and ER to Relational Schema.

Fall 200616Database Management Systems

Weak EntitiesWeak Entities

course-offering (courseno, secno, year, semester, time, room)

Page 17: COMP231 Tutorial 1 ER Model and ER to Relational Schema.

Fall 200617Database Management Systems

Relationships (Not defining weak entities)Relationships (Not defining weak entities)

Page 18: COMP231 Tutorial 1 ER Model and ER to Relational Schema.

Fall 200618Database Management Systems

Relationships (Not defining weak entities)Relationships (Not defining weak entities)

enrolls (sid, courseno, secno, semester, year, grade)

teaches (courseno, secno, semester, year, iid)

requires (maincourse, prerequisite)

Page 19: COMP231 Tutorial 1 ER Model and ER to Relational Schema.

Fall 200619Database Management Systems

Relationships with Weak EntitiesRelationships with Weak Entities

Page 20: COMP231 Tutorial 1 ER Model and ER to Relational Schema.

Fall 200620Database Management Systems

Relationships with Weak EntitiesRelationships with Weak Entities

There is no extra table for the relationship between a weak entity and its strong entity.

The relationship is already present in the schema for the weak entity.

course-offering (courseno, secno, year, semester, time, room)

Page 21: COMP231 Tutorial 1 ER Model and ER to Relational Schema.

Fall 200621Database Management Systems

Relational Schemas for a UniversityRelational Schemas for a University

course (courseno, title, syllabus, credits)

student (sid, name, program)

instructor (iid, name, dept, title)

course-offering (courseno, secno, year, semester, time, room)

enrolls (sid, courseno, secno, semester, year, grade)

teaches (courseno, secno, semester, year, iid)

requires (maincourse, prerequisite)

Page 22: COMP231 Tutorial 1 ER Model and ER to Relational Schema.

Fall 200622Database Management Systems

Submitted for –Submitted for –www.mycollegebag.inwww.mycollegebag.in