In this article we will discuss about Entity Relationship Model (ER Model) and ER diagram. Before reading this article, it is advised to have a basic understanding about what is database management system and related concepts. In case, if you dont have much knowledge about these things, you can read our earlier article: Database Management System and Concepts
Data is set of observations which provide details about an object or phenomenon. Data is normally stored as files in the form of tables in a database. In an application many such files exist (physically) together. These files are connected logically.
Table of Contents
Entity Relationship model or ER diagram is used to develop a conceptual diagram of how data in the database should be connected.
Any application is developed or completed in several phases for meeting the requirement of user. For example collection of requirements, analysis, design, execution, testing, implementation, debugging etc., are several stages in application development.
In each development phase, there exist several activities. The data required by the activities, connection between the activities and activities results etc are documented before starting out the actual development.
Entity Relationship Diagram:
A language is specifically designed for this purpose of documentation. Here, instead of using simple text, some diagrams are used for representing all these things.
This is typically a flow chart and is named as entity relationship diagram. Entity relationship model makes use of this diagram for describing the structure of a database.
ER diagrams are very much useful in debugging the database systems. They provide a logical view of data flow and accessibility and result information.
For same application ER diagram can be drawn differently by different people, because an application can solved using variety of logic.
To completely understand ER diagram or ER model, it is important to understand various components of ER model.
Components of Entity Relation Model or ER diagram:
Database is made up of three important things, which are entity, attributes and relationships.
This is first component of E R Model. Entities are objects that are described using data in a database. For example, in a college management system, College, Department, Course etc are all entities. These entities are described using data. College is an entity, and it is described with details such as college name, college code etc.
As already stated above, entities have several characteristics. These characteristics are defined or described in a database using attributes. In the above example, for the entity college, the details shown i.e., college name, code etc., are attributes.
However, all attributes are not similar in behavior and definition. Hence, they are categorized into several types.
a) Atomic Attributes
b) Composite Attribute
c) Single valued Attribute
d) Multi valued Attribute
e) Stored Attribute
f) Derived Attribute
g) Null Attribute
h) Key Attribute: There exist a constraint in specifying value for key attribute.
Graphics or Symbols Used in ER Diagram:
Entity is represented using a rectangular box. Inside the box, some text (noun) is placed which represents the name of entity.
Relationship between 2 entities is represented using a rhombus shape or diamond shape box. Relationship between the 2 entities stated in the box. It is normally a verb, that helps in understanding what happens with the relationship.
Attributes are represented using ellipse or oval shape symbols.
Primary Attribute Keys are represented in the same way as normal attributes, but the text or attribute value is underlined in the oval shape.
In case of foreign key attribute, the attribute name is underlined using a dotted line.
Cardinality defines no of relationships present between the elements in the data sets. There exist 1 to 1, 1 to many and many to many type of relationships. The cardinality present between the entities is also represented in the entity relationship diagram.
For example, student and course are 2 entities. A student can take 1 or more courses. Similarly, a course can have 1 or more students. Here, the cardinality associated between the entities is many to many. Because, same student may present in many courses and same course will have many students.