DATABASE SYSTEMS INTRODUCTION TO ER DIAGRAM Er Rakesh
DATABASE SYSTEMS INTRODUCTION TO ER DIAGRAM Er. Rakesh Kumar Singh
OUTLINE • • ER Diagram Symbols Representing Entities/Attributes Representing Relationships Some Examples 2
ER DIAGRAM OVERVIEW • An entity-relationship diagram is a graphical depiction of – organizational system elements and – the association among the elements. ER Diagram can be used to represent Entities Attributes Relationships 3
ER DIAGRAM OVERVIEW Entity Examples Attributes Person Place Object Event or concept in the user environment about which the organization wishes to maintain data A named property or characteristic of an entity that is of interest to an organization An Attribute can be Simple Composite Multivalued Derived 4
ER DIAGRAM OVERVIEW • A Relationship is: – An association between the instances of one or more entity types that is of interest to the organization. • Association indicates that an event has occurred or that there is a natural link between entity types. • Relationships are always labeled with verb phrases 5
ER DIAGRAM OVERVIEW • Relationship name is a verb phrase • Avoid vague names • Guidelines for defining relationships • Definition explains what action is being taken and why it is important • Give examples to clarify the action • Optional participation should be explained 6
ER DIAGRAM OVERVIEW In ER Diagram, relationships are represented in a diamond shaped symbol Student Relationships Course 7
ER DIAGRAM SYMBOLS • Rectangle – entity • Ellipse – attribute • Diamond – relationship • Double ellipse – multivalued attribute • Dashed ellipse – derived attribute • Double line – total participation (existence dependency) • Double rectangle – weak entity • Double diamond – relationships for weak entity 8
RELATIONSHIP CARDINALITY • Identifies the maximum number of instances in which an entity participates in a relationship. • Types of relationship cardinality • One – to – one • One – to – many • many – to – many 9
ONE – TO – ONE Manager Head of Department (Ho. D) Automobile manages heads has Company Department Engine 10
ONE – TO – MANY Project Manager Instructor Husband manages teaches marries Project Section Wife 11
MANY – TO – MANY Employee Student works on attends Project Class 12
EXAMPLE 1 • A university registrar’s office maintains data about the following entities: a) courses, including number, title, credits, syllabus, and prerequisites; prerequisites b) course offerings, including course number, number year, semester, section number, instructor(s), timings, and classroom; instructor c) students, including student-id, name, and program; d) 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 for must be appropriately modeled. • Construct an E-R diagram for the registrar’s office. Document all assumptions that you make about the mapping constraints. 13
EXAMPLE 1 • The entities mentioned in the example are: Courses Students Instructors Course Offerings Represent each of the above entities using ERD 14
COURSE ENTITY Code Title Syllabus Courses Credit Requires Prerequisite 15
STUDENT ENTITY Student. ID Name Major Student Admission Date 16
INSTRUCTOR ENTITY Instructor. ID Name Title Instructor Department 17
COURSE OFFERING ENTITY Year Semester Section no. Course Offering Year Room 18
student. ID name student time room semester instructor. ID courseofferings enrols program year instructor teaches section_no name dept title is offered course_no course requires Prerequisite credits title syllabus 19
COMPANY SYSTEM ER DIAGRAM • The requirements of a company system may contain entities: – DEPARTMENT – PROJECT – EMPLOYEE – DEPENDENT 20
? 21
- Slides: 21