DBMS, RDBMS Concepts BBSR, 06\11\2012, Prof. Suraj Sharma, IIIT-Bh Insert Client/Partner logo.

Slides:



Advertisements
Similar presentations
ER Model For a college DB
Advertisements

Chapter 2: Entity-Relationship Model
Chapter 6: Entity-Relationship Model
Temple University – CIS Dept. CIS616– Principles of Database Systems
Chapter 6: Entity-Relationship Model (part I)
Chapter 2: Entity-Relationship Model
Weak Entity Sets An entity set that does not have a primary key is referred to as a weak entity set. The existence of a weak entity set depends on the.
Ch5: ER Diagrams - Part 1 Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
Entity Relationship (ER) Modeling
Entity Relationship (ER) Modeling
Text-Book Chapters (7 and 8) Entity-Relationship Model
CS157A Lecture 3 ER Diagram Prof. Sin-Min Lee Department of Computer Science San Jose State University.
Databases Revision.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
1–1 The E-R Model Prof. Sin-Min Lee Department of Computer Science.
Slides adapted from A. Silberschatz et al. Database System Concepts, 5th Ed. Entity-Relationship Model Database Management Systems I Alex Coman, Winter.
ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers.
1 Data Modelling Which data to include in the database.
Chapter 2: Entity-Relationship Model (Continued)
Entity-Relationship Model
Data Modeling Using the Entity-Relationship Model
Database System Concepts, 5th Ed. Chapter 6: Entity-Relationship Model.
Entity-Relationship Model
Module Title? Data Base Design 30/6/2007 Entity Relationship Diagrams (ERDs)
Chapter 5 Entity Relationship (ER) Modelling
1 ER Modeling BUAD/American University Entity Relationship (ER) Modeling.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
Chapter 6: ER – Entity Relationship Diagram
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
Chapter 7 Database Design and The E–R Model. 2 Goals n Facilitate DB design and represent the overall logical structure of the DB. n Definition Entities.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts DB Schema Design: the Entity-Relationship Model What’s the use of the E-R model? Entity Sets.
Entity-Relationship Model Using High-Level Conceptual Data Models for Database Design Entity Types, Sets, Attributes and Keys Relationship Types, Sets,
The Hong Kong University of Science and Technology COMP3311 Spring 2013 Tutorial 1 ER Diagrams.
1 A Demo of Logical Database Design. 2 Aim of the demo To develop an understanding of the logical view of data and the importance of the relational model.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
Chapter 2 : Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping Constraints Keys E-R Diagram Extended E-R Features Design of.
UNIT_2 1 DATABASE MANAGEMENT SYSTEM[DBMS] [Unit: 2] Prepared By Lavlesh Pandit SPCE MCA, Visnagar.
ICOM 5016 – Introduction to Database Systems Lecture 5 Dr. Manuel Rodriguez Department of Electrical and Computer Engineering University of Puerto Rico,
Computing & Information Sciences Kansas State University Friday, 26 Sep 2008CIS 560: Database System Concepts Lecture 13 of 42 Friday, 26 September 2008.
Keys for Relationship Sets The combination of primary keys of the participating entity sets forms a super key of a relationship set. – (customer-id, account-number)
Entity-Relation Model. E-R Model The Entity-Relationship (ER) model was originally proposed by Peter in 1976 ER model is a conceptual data model that.
Database and Information Retrieval System
advanced data modeling
Exam 1 Review Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008.
Data Modeling Using the Entity-Relationship (ER) Data Model.
CST203-2 Database Management Systems Lecture 4. Student entity NIDFNameLNameRegNoExamIdBirthdate.
CSE 412/598 DATABASE MANAGEMENT COURSE NOTES 3. ENTITY-RELATIONSHIP CONCEPTUAL MODELING Department of Computer Science & Engineering Arizona State University.
1 Entity Relationship Diagram. ER proposed by Peter Chen ER diagram is widely used in database design Represent conceptual level of a database.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Mapping Constraints Keys.
Lecture 26 Enterprise Systems Development ( CSC447 ) COMSATS Islamabad Muhammad Usman, Assistant Professor.
Enhanced Entity-Relationship and UML Modeling. 2.
Topic 3: ER – Entity Relationship Model (ERM) 6/12/
Chapter 2: Entity-Relationship Model
Entity Relationship (E-R) Model
COP Introduction to Database Structures
Entity-Relationship Model
Enhanced Entity-Relationship and Object Modeling Objectives
Entity-Relationship Model
Entity Relationship Model
Entity-Relationship Model
Chapter 2: Entity-Relationship Model
Chapter 7 Entity-Relationship Model
Outline of the ER Model By S.Saha
Entity-Relationship Model
Database Modeling using Entity Relationship Model (E-R Model)
Chapter 6: Entity-Relationship Model
Chapter 7: Entity-Relationship Model
Chapter 7: Entity-Relationship Model
Entity Relation Model Tingting Zhang.
Chapter 2: Entity-Relationship Model
Presentation transcript:

DBMS, RDBMS Concepts BBSR, 06\11\2012, Prof. Suraj Sharma, IIIT-Bh Insert Client/Partner logo

2 Copyright © Capgemini All Rights Reserved Presentation Title | Date Entity-Relationship Model  It is always better to represents all the business rules in pictorial format so that the business users can understand and review the business rules easily and correctly.  One such technique, which is commonly used for designing of the databases, is Entity-Relationship Modeling (E-R Modeling). The diagram used in this technique is called Entity Relationship Diagram (ERD).  Entity Relationship Diagram (ERD) was first defined in 1976 by Peter Chen. Since then Charles Bachman and James Mart in have added some small refinements to the basic ERD principles. Due to its simplicity and ease of use, this technique attracted considerable attention during early 1990’ s in both industry and research community.

3 Copyright © Capgemini All Rights Reserved Presentation Title | Date Entity and Relationship  Before learning E-R diagrams technique in detail let us understand Entity and Relationship.  Entity  An Entity is a ‘thing’ or ‘object’ in the real world that is distinguishable from all other objects. Entity is a common word anything real or abstract, about which we want to store data. Entity types fall into five categories: roles, events, locations, tangible things or concepts.  Example  Some examples of entities are employee, hockey match, campus, book and department. Department is an entity, and Education & Research, HR, Finance, etc., are instances of the department entity. Similarly Henry, Luther, Crystal, Jane etc., are instances of employee entity.

4 Copyright © Capgemini All Rights Reserved Presentation Title | Date Entity and Relationship  Attribute  An attribute is a characteristic property of an entity. An entity could have multiple attributes. For each of permitted attribute, there is a set of permitted values, called the domain, or value set.  Example  For an entity car, the attributes would be the color, model number, number of doors, right or left hand drive etc.  Attribute Types:  Simple or composite  Single-valued or multivalued  Derived  Relationship  Relationship is a natural association that exists between one or more entities.  Example  Employee borrows books from the library.

5 Copyright © Capgemini All Rights Reserved Presentation Title | Date Constraints  E-R enterprise schema may define certain constraints to which the contents of a database must conform. 1.Mapping Cardinalities 2.Key constraints 3.Participation constraints

6 Copyright © Capgemini All Rights Reserved Presentation Title | Date Mapping Cardinality  Cardinality of relationship defines the type of relationship between two participating entities.  Example:  One employee can take many books from library. One book can be taken by only one employee. Cardinality of relationship between employee and book is “one to many”.  One person can sit on only one chair at any point of time. One chair can accommodate only one person in a given point of time. This relationship has “one to one” cardinality.  There are four types of cardinality relationship.  one-to-one  one-to-many  many-to-one  many-to-many

7 Copyright © Capgemini All Rights Reserved Presentation Title | Date One to One Relationship  In this relationship, one instance of entity is related to another instance of the entity. Both participating entities have a one to one relationship.  Example  One person (P1,P2,P3,P4) can sit on only one chair at any point of time. And also one chair (C1,C2,C3,C4) can accommodate a maximum of one person at any given time. In this relationship both the participating entities have one-to-one relationship. P1. P2. P3. P4.. C1. C2. C3. C4

8 Copyright © Capgemini All Rights Reserved Presentation Title | Date One to Many Relationship  One instance of entity is related to multiple instance of another entity.  Example  One organization(O1,O2,O3) can have many employees but one employee (E1,E2,E3,E4,E5) can work only for one organization. O1. O2. O3.. E1. E2. E3. E4. E5

9 Copyright © Capgemini All Rights Reserved Presentation Title | Date Many to One Relationship  One instance of entity is related to multiple instance of another entity.  Example  One organization(O1,O2,O3) can have many employees but one employee (E1,E2,E3,E4,E5) can work only for one organization.. O1. O2. O3 E1. E2. E3. E4. E5.

10 Copyright © Capgemini All Rights Reserved Presentation Title | Date Many to Many Relationship  In this many to many relationship multiple instances of one Entity are related to multiple instances of another Entity.  Example  One student (S1,S2,S3,S4) is enrolled for many courses (C1,C2,C3,C4) and one course is enrolled by many students.  Many to many relationship is superset of all the above mentioned relationships. All other relationships are special case of many to many relationships. S1. S2. S3. S4.. C1. C2. C3. C4

11 Copyright © Capgemini All Rights Reserved Presentation Title | Date Key Constraints  Conceptually, individual entities are distinct; from a database perspective, however, the difference among them must be expressed in terms of their attributes.  Therefore, the values of the attribute values of an entity must be such that they can uniquely identify the entity. In other words, no two entities in an entity set are allowed to have exactly the same values for all attributes.  A key allow us to identify a set of attributes that suffice to distinguish entities from each other.  Entity Sets  Super key  Candidate key  Primary key

12 Copyright © Capgemini All Rights Reserved Presentation Title | Date Participation Constraints  The participation of an entity set E in a relationship set R is said to be total if every entity in E participates in at least one relationship in R.  If only some entities in E participate in relationship in R, the participation of entity set E in relationship R is said to be partial.

13 Copyright © Capgemini All Rights Reserved Presentation Title | Date E-R Diagram Notations  Entity An entity is an object or concept about which business user wants to store information.  Weak Entity A weak entity is dependent on another entity to exist. Example bank branch depends upon bank name for its existence. Without bank name it is impossible to identify bank branch uniquely.  Attribute At tributes are the properties or characteristics of an entity.  Key Attribute A key at tribute is the unique, distinguishing characteristic of the entity. For example, an employee’s employee number might be the employee’s key attribute.  Key Attribute A key at tribute is the unique, distinguishing characteristic of the entity. For example, an employee’s employee number might be the employee’s key attribute. Entity Attribute

14 Copyright © Capgemini All Rights Reserved Presentation Title | Date E-R Diagram Notations  Multivalued attribute A multivalued attribute can have more than one value. For example, an employee entity can have multiple skill values.  Derived attribute A derived attribute is based on another attribute. For example, an employee’s monthly salary is based on the employee’s basic salary and house rent allowance.  Relationships Text Relationships illustrate how two entities share information in the database structure.  Recursive relationship Text In some cases, entities can be self-linked. For example, employees cansupervise other employees.  Recursive relationship Text In some cases, entities can be self-linked. For example, employees cansupervise other employees. Attribute Relationship Employee

15 Copyright © Capgemini All Rights Reserved Presentation Title | Date E-R Diagram Notations  Cardinality Cardinality specifies how many instances of an entity relate to one instance of another entity. N represent ‘MANY’ and 1 represents ‘ONE’ cardinality Account Customer N 1  Lines Which link attributes to entity set and entity sets to relationship sets  Double Lines Which indicate total participation of an entity in a relationship set

16 Copyright © Capgemini All Rights Reserved Presentation Title | Date Modeling using E-R Diagrams  A model is an abstract form of any system or process that hides the unnecessary details, while highlighting those details important to the application.  We have noticed the model of huge campuses or buildings which help to visualize the structure, before they are built. On similar lines, we can also model our software applications before they are developed.  This will help the business users to visualize the application before it is developed and suggest changes, if it is not as per their requirement. Modeling the databases using E-R diagrams is called as E-R Modeling.  This technique is also called as Top-Down approach, because one need not identify all the attributes to model the system using this technique.

17 Copyright © Capgemini All Rights Reserved Presentation Title | Date Steps in E-R Modeling  Usually the following six steps are followed to generate E-R Models. 1.Identify the entities  Look for general nouns in requirement specification document which are of business interest to business users 2.Find relationships  Identify the natural relationship and their cardinalities between the entities 3.Identify the key attributes for every entity:  Identify the attribute or set of attributes which can identify instance of entity uniquely 4.Identify other relevant attributes:  Identify other attributes which are interest to business users and want to store the information in database

18 Copyright © Capgemini All Rights Reserved Presentation Title | Date Steps in E-R Modeling 5.Complete E-R diagram:  Draw complete E-R diagram with all attributes including primary key 6.Review your results with your business users  Look at the list of attributes associated with each entity to see if anything has been omitted.  Note that while this is an iterative approach and one cannot come to a final E-R model in a single step. It requires a great deal of patience and numerous revisions before the model is created.

19 Copyright © Capgemini All Rights Reserved Presentation Title | Date Problem  Let us apply the above methodology to model, University database application.  An university has many departments  Each department has multiple instructors; one among them is the head of the department  An instructor belongs to only one department  Each department offers multiple courses, each of which is taught by a single instructor  A student may enroll for many courses offered by different departments

20 Copyright © Capgemini All Rights Reserved Presentation Title | Date Solution Sept 1: Identify the Entities  Generally the entities will have multiple instances in a given business scenario. As per this guideline, we can identify the following entities: 1.DEPARTMENT 2.COURSE 3.INSTRUCTOR 4.STUDENT  “Head of the department” is NOT an Entity. It is a relationship between the Instructor and department entities.  Note: One may be tempted to identify “university” as an entity, but it is a false entity because it has only one instance.

21 Copyright © Capgemini All Rights Reserved Presentation Title | Date Solution Sept 2: Find relationships  We can derive the following relationships: 1.The department offers multiple courses and each course belongs to only one department, hence cardinality between department and course is one to many. 2.One course is enrolled by multiple students and one student enrolls for multiple courses, hence the relationship is many to many. 3.One department has multiple instructors and one instructor belongs to one and only one department, hence the relationship is one to many. Department Course 1 N Offers Course Student M N Enrolled By Department Instructor 1 N Has

22 Copyright © Capgemini All Rights Reserved Presentation Title | Date Solution Sept 2: Find relationships  We can derive the following relationships: 4.Each department has one “Head of Department ” and one Instructor is “Head of Department ” for only one department, hence the relationship is one to one. 5.One course is taught by only one instructor but one instructor teaches many courses, hence the relationship between course and instructor is many to one.  The relationship between instructor and student need NOT be defined for following reasons: 1.There is no business significance in this relationship. 2.We can always derive this relationship indirectly through course and instructor, and course and students. Department Instructor 1 1 Headed by Course Instructor N 1 Is Taught by

23 Copyright © Capgemini All Rights Reserved Presentation Title | Date Solution Sept 3: Identify the Key Attributes 1.DName (Department Name) which identifies the department uniquely will be the key attribute for “DEPARTMENT” entity. 2.STUDENT# (Student Number) is the key attribute for “STUDENT” entity. 3.IName (Instructor Name) is the key attribute for “ INSTRUCTOR” entity. 4.COURSE# (Course Number) is the key attribute for COURSE entity.

24 Copyright © Capgemini All Rights Reserved Presentation Title | Date Solution Sept 4: Identify other relevant Attributes 1.For the “Department” entity, the relevant attribute other than “Department Name” is “Location”. 2.For the “Course” entity, the relevant attributes other than “Course Number” are “Course Name”, “Duration” and “Pre Requisite”. 3.For the “Instructor” entity, the relevant attributes other than “ Instructor Name” are “Room Number” and “Telephone Number”. 4.For the “Student” entity, the relevant attributes other than “Student Number” are “Student Name” and “Date of Birth”.

25 Copyright © Capgemini All Rights Reserved Presentation Title | Date Solution Sept 5: Complete E-R Diagram  After considering all the above mentioned guidelines one can generate the E-R Model for the university database as shown Department Course Instructor Student Offers Headed By Has Dept_name Location Pre_Requisite Course# Course_name Duration Inst_name Room# Telephone# DOB Student# Std_name Enrolled By Is Taught by 1 N N 1 N N M

26 Copyright © Capgemini All Rights Reserved Presentation Title | Date Weak Entity Sets  An entity set may not have sufficient attributes to form a primary key, such an entity set is termed a weak entity set.  An entity set that has a primary key is termed a strong entity set.  Example Payment(payment_number, payment_date, payment_amount)  The existence of a weak entity set depends on the existence of a identifying entity set  it must relate to the identifying entity set via a total, one-to-many relationship set from the identifying to the weak entity set.  Identifying relationship depicted using a double diamond.  The discriminator (or partial key) of a weak entity set is the set of attributes that distinguishes among all the entities of a weak entity set.  The partial key of a weak entity set is formed by the primary key of the strong entity set and become a primary key for the weak entity set.

27 Copyright © Capgemini All Rights Reserved Presentation Title | Date Weak Entity Sets  We depict a weak entity set by double rectangles.  We underline the discriminator of a weak entity set with a dashed line.  payment_number – discriminator of the payment entity set  Primary key for payment – (loan_number, payment_number)

28 Copyright © Capgemini All Rights Reserved Presentation Title | Date Spacialization  The process of designating subgroupings within an entity set is called specialization.  The label ISA stands for ‘is a’  The ISA relationship may also be referred to as a superclass-subclass relationship.

29 Copyright © Capgemini All Rights Reserved Presentation Title | Date Generalization  The commonality can be expressed by generalization, which is a containment relationship that exists between a higher-entity set and one or more lower-entity sets  Generalization is used to emphasize the similarities among lower-level entity set and to hide the differences.

30 Copyright © Capgemini All Rights Reserved Presentation Title | Date Attribute Inheritance  A crucial property of the higher-level and lower-level entities created by specialization and generalization is attribute inheritance.

31 Copyright © Capgemini All Rights Reserved Presentation Title | Date Aggregation  Aggregation is an abstraction through which relationships are treated as higher level entities.