Tuesday 14 February 2017

E-R Diagram

ER-Diagram is a visual representation of data that describes how data is related to each other
example of er-diagram
ER diagrams symbols

Components of E-R Diagram

  1. Entity:  Entity refers to a real world object that might depict a table in an SQL Server database. Databases are often constructed in the basis of an Entity-relationship diagram.
Entity example
2.Weak Entity : In a relational database, weak entity  is a entity that cannot be uniquely identified by its attributes, it should take the help  of foreign key in conjunction with its attributes to create a primary key.
weak Entity example
3. Attribute: It defines the properties of the table.or example, Name, Age, Address etc can be attributes of a Student.
attribute example
4. Key Attribute: It represents  the primary key in a particular entity/element
key attribute example
For example, id in the student entity type.
5. Non-Key Attribute: These are the attributes other than candidate key  in a given table.For example in Name, First Name is non-Key Attribute which does not have the main characteristics of the entity.
6. Composite Attribute: In this type, all the attributes are arranged in a tree-structured way and every node is connected to its attribute.
Composite Attributes
Relationship:
It describes the bond  between the entities.
There are generally three types of relationships:
1. Binary relationship
2. Recursive Relationship
3. Ternary Relationship

BINARY RELATIONSHIP

Binary Relationship means relation between two Entities. This is further divided into three types.
  1. One to One : This type of relationship is rarely seen in real world.
one-to-one example
2. One to Many : It reflects business rule that one entity is associated with many number of same entity. The example for this relation might sound a little weird, but this means that one student can enroll to many courses, but one course will have one Student.
one-to-many example
Many to One : It reflects business rule that many entities can be associated with just one entity. For example, Student enrolls for only one Course but a Course can have many Students.
one-to-many example

RECURSIVE RELATIONSHIP

When an Entity is related with itself it is known as Recursive Relationship.
recursive relationship example

TERNARY RELATIONSHIP

Relationship of degree three is called Ternary relationship.

No comments:

Post a Comment