Entity Relationship Model in Database System

kamalakantas 36 views 19 slides Jul 02, 2024
Slide 1
Slide 1 of 19
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19

About This Presentation

Entity Relationship Model


Slide Content

Entity-Relationship Model in Database By Dr. Kamalakanta Sethi

Entity-Relationship Model It is a high level data model used for developing conceptual design of the database. ER model was introduced by Peter Chenn in 1976. It works around real world entities and relationship among them. ER describes the structure or blueprint of the database with the help of a diagram called Entity-Relationship diagram. The main components of ER Model is Entity set Relationship set

Entity Set Entity is a real world object having either physical existence (e.g., student, house) or conceptual existence (e.g., company, job, etc ). Entity set is a collection of similar type of entities that share same properties (or attributes). Ex: A student entity set consists of all students of a school Entity set is represented by rectangle in ER diagram.

Attributes Attributes are used to describe the properties of an entity. Ex: A student entity may have different attributes such as Name, Age, Mobile No, etc. For each attribute there is a set of permitted values called domain of that attribute. Ex: A student Name can not be numeric There are different types of attributes simple and composite attribute single valued and multi-valued attribute derived attribute key attribute

Relationship set The logical association among entities is called  relationship . Ex: Enrolled in’ is a relationship that exists between entities   Student  and  Course . A set of relationships of similar type is called relationship set.

Cardinality ratio Cardinality ratio defines the number of entities of an entity set A which can be associated with number of entities of another entity set B via a relationship. Based on cardinality, there are four types of relationships one to one relationship one to many relationship many to one relationship many to many relationship

Participation Constraints Participation constraints defines whether all entities in the entity set are participating in the relationship set or not. Total Participation Partial Participation Total Participation: Each entity in the entity set must have at least one relationship in the relationship set. (here all entities) Partial Participation: Each entity in the entity set may or may not have relationship in the relationship set.

ER Diagram drawing steps Step 1 − Identifying the entity sets. Step 2 − Identifying the attributes for the given entity sets Step 3 − Identifying the Key attributes Step 4 − Identifying the relationship between entity sets Step 5 − Identify cardinality constraints Step 6 − identify participation constraints 28-Feb-22 8

ER diagram for Banking system Bank have Customer. Banks are identified by a name, code, address of main office. Banks have branches. Branches are identified by a branch_no ., branch_name , address. Customers are identified by name, cust -id, phone number, address. Customer can have one or more accounts. Accounts are identified by account_no ., acc_type , balance. Customer can avail loans. Loans are identified by loan_id , loan_type and amount. Account and loans are related to bank’s branch. 28-Feb-22 9

ER Diagram for Banking System

Conversion of ER Model to Relational Model

 Rule 1: For strong entity s et with only simple attributes A strong entity set with only simple attributes will require only one table in relational model. Attributes of the table will be the attributes of the entity set. The primary key of the table will be the key attribute of the entity set. 28-Feb-22 12

- Relational model does not handle composite attributes. A strong entity set with any number of composite attributes will require only one table in relational model. While conversion, simple attributes of the composite attributes are taken into account and not the composite attribute itself. 28-Feb-22 13  Rule 2: For strong entity s et with only composite attributes

A strong entity set with multi valued attributes will require two tables in relational model. One table will contain all the simple attributes (add simple attributes of the composite attribute if it is present) along with key attribute . The key attribute become primary key of the table. Other table will contain the key attribute and all the multi valued attributes. Key attribute and multivalued attribute of entity set becomes primary key of table . 28-Feb-22 14 Roll No City 1 Balasore 1 Jamshedpur 3 Bhubaneswar Roll No Mobile No 1 9437018765 1 8249544124 2 9834587698  Rule 3: For strong Entity Set with multi-valued attributes

The following four cases are possible Case-1 :  Binary relationship with cardinality ratio M:M (many to many relationship) Case-2 :  Binary relationship with cardinality ratio 1:M (one to many relationship) Case-3 :  Binary relationship with cardinality ratio M:1 (many to one relationship) Case-4 :  Binary relationship with cardinality ratio 1:1 (one to one relationship ) 28-Feb-22 15  Rule 4: For binary relationships with cardinality constraints

Case-1:  Binary relationship with cardinality ratio M:M (many to many relationship) To convert this Relationship set into relational schema, Relationship set is mapped as separate relation Key attributes of participating entity sets are mapped as primary key for that relation.

Case-2 and Case-3: one to many and many to o ne relationship Separate relation is created for all participating entity sets . Key attribute of one side entity set is mapped as foreign key in many side relation .

Case-4:  Binary relationship with cardinality ratio 1:1 (one to one) Here, two tables will be required. Either combine ‘R’ with ‘A’ or ‘B’ o ption-01 : AR (  a1  , a2 , b1 ) B (  b1  , b2 ) o ption-02 : A (  a1  , a2 ) BR ( a1 ,  b1  , b2 )

Thank you… 28-Feb-22 19
Tags