Advertisement

Entity Relationship Model - ER Model in dbms

 Entity Relationship Diagram – ER Diagram in DBMS

 An Entity–relationship model (ER model)  is based on the theory of a real world which consist of a set of basic objects, which are called entities and relationships among these objects. an entity exists as an object and is distinguishable from other objects.


For example:-Account number 1000 at the HDFC bank is an entity that uniquely identifies one particular account. Similarly, a car with its registration number DL 2D F/-8848 is an entity, since it uniquely identifies one particular car in the country.


What is an Entity Relationship Diagram (ER Diagram)?

 The Entity Relationship Model(ER-Model) is a high level data model. It is based on perceptions of  a real worlds that consist of a  collection of basic objects, called entities, and of relationship among these objects. It was developed to facilitate database design by allowing specification of an enterprise schema which represent the overall logical structure of a database.  


E-R Diagram Notations-




Components of a ER Diagram

Components of ER Diagram

As shown in the above diagram, an ER diagram has three main components: 
  1.  Entity 
  2.  Attribute 
  3.  Relationship

  1.  Entity:
 An entity is an object or component of data Any distinguishable person, place, thing, event, or concept about which information is kept or an object which can be distinctly identified and distinguished and represented in a database, or anything about which we store information is called entity.


 For example:
 In the following ER diagram we have two entities Student and College and these two entities have many to one relationship as many students study in a single college. We will read more about relationships later, for now focus on entities. .





  2. Weak Entity: 

Weak entities are dependent entities, against regular entities that are independent. The weak entity is represented by a double rectangle. 


For example – a bank account cannot be uniquely identified without knowing the bank to which the account belongs, so bank account is a weak entity. 



Weak Entities :

A weak entity is a type of entity which doesn't have its key attribute. It can be identified uniquely by considering the primary key of another entity. For that, weak entity sets need to have participation


    2. Attribute

 An attribute describes the entity to which they are associated. A particular instance of an attributes is a value. An attribute is represented as Oval in an ER diagram. There are four types of attributes: 

  1. Composite attribute 
  2.  Multivalued attribute 
  3.  Derived attribute 
  4. Key Attribute 
   
1. Key attribute: 

A key attribute can uniquely identify an entity from an entity set. For example, student roll number can uniquely identify a student from a set of students. Key attribute is represented by oval same as other attributes however the text of key attribute is underlined. 





2. Composite attribute:

Composite attribute are those attribute which can be divided into sub-parts(i.e., other attributes). For example, In student entity, the student address is a composite attribute as an address is composed of other attributes such as pin code, state, country. 







3. Multivalued attribute: 

The attribute which has a set of values for a specific entity is called Multivalued attribute. It is represented with double ovals in an ER Diagram. 

For example – A person can have more than one phone numbers so the phone number attribute is multivalued. 


4. Derived attribute: 

The value of this type of attribute can be derived from the values of other related attributes and entities.
An attribute takes a null values when an entity does not have a value for it. The null value may indicate "not applicable".  It is represented by dashed oval in an ER Diagram. 


For example – Person age is a derived attribute as it changes over time and can be derived from another attribute (Date of birth). 

E-R diagram with multivalued and derived attributes: 




3. Relationship : 

Cardinality

The mapping of relationship depends on the type of relationship .Each type of  relationship maps to tables in a different manner in the RDBMS(Relational database management system).A relationship is represented by diamond shape in ER diagram, it shows the relationship among entities. 

There are four types of cardinal relationships: 
1. One to One 
2. One to Many 
3. Many to One 
4. Many to Many 


1. One to One Relationship :

 A pair of tables is defined as having a one to one relationship if one record in the first table is related to only one record in the second table. 
For example- a person has only one passport and a passport is given to one person.  




2. One to Many Relationship :

A relationship is defined as one to many when a single record in the first table points to many records in the second table. However, a single record in the second table can only point to one record in the first table .

 For example – a customer can place many orders but a order cannot be placed by many customers. 




3. Many to One Relationship :


When more than one instances of an entity is associated with a single instance of another entity then it is called many to one relationship. 

For example – many students can study in a single college but a student cannot study in many colleges at the same time. 




4. Many to Many Relationship:

A many to many relationship exists between two tables if a single record in the first table points to more than one records in the second table and a single record in the  second table points to many records in the first table .

 For example- a can be assigned to many projects and a project can be assigned t o many students. 

conclusion:

These were some of the point discussed in the post- ER Model in DBMS,  its entity and notations. 
There is more coming with the next post keep reading...











Post a Comment

0 Comments