An E-R (Entity-Relationship) Diagram can express the overall logical structure of a database graphically. A model that represents system data by entity and relationship sets is called E-R (Entity-Relationship) model. The Entity-Relationship (E-R) data model is based on a perception of a real word which consists of a set of basics objects.
Components of E-R models
(i) Entity
(ii) Attributes
(iii) Relationship
(iv) Key attributes
Entity
An entity is a class of person, place, object, events or concepts about which we need to collect and store data. Each entity is distinguishable from the other entities. Categories of different entities include:
Ø Person: employee, customer, student, supplier etc.
Ø Place: Branch office, building, room etc.
Ø Object: book machine, Vehicle etc.
Ø Events: sale, reservation, registration, order etc.
Entity Set
An entity set is the collection of entities of the same type i.e. the entities which share common properties or attributes .for example the set of all employee of an organization can be called as the entity set.
Entity Type
An entity type defines a collection of entity that has the same attributes. Each entity type in the same database is described by its name and attributes.
An entity type describe the schema for a set of entities that shared the same structure. The collection of entities of a particular entity type is grouped into an entity set, which is also called the extension of the entity type.
Attributes
An attribute is a descriptive property or characteristic of an entity. Each entity can have a number of characteristics. The characteristics of an entity are called attributes.
Some attributes can be logically grouped into super attributes called compound attributes. For example an employee name is a compound attributes consisting of first names, middle name and last name.
Type of Attributes
(i) Composite V/S Simple Attributes
Composite attributes can be divided into smaller sub parts, which represent more basic attributes with independent meaning. For example the address attribute can be further subdivided into H_No, Street No, city, pin code etc.
Simple or Atomic Attributeess are those attributes that are not divisible for example phone, age etc.
(ii) Single value v/s Multiple values attributes
Most attributes have a single value for a particular entity such attributes is called single values. For example age, name etc.
In same case s an attribute can have a set of values for the same entity such attributes are called multi values attributes for example Phone no, address, college degree etc.
(iii) Store v/s Derive Attributes
In same case two or more attributes are relative for e.g. the age and birth date attributes of a person for a particular person, the values of age attributes can be derive from the current date and the birth date. Hence the age attribute is called a derived attribute, which is said to be derivable form the birth date attribute that is called the stored attribute.
(iv) Complex Attributes
The composite and multi values attributes can be nested in an arbitrary way such attributes are called complex attributes. The components of a composite attributes are show within parenthesis () and multi values attributes are displayed within braces {}
Relationship
Whenever an attributes of an entity type related to an attributes of another entity type there exist some relationship between them. For example the attributes manager of DEPARTMENT refers to an employee who manage that DEPARTMENT.
Relationship Type
A relationship type R among N entity types. E1,E2, ……………….En defines a set of relationship or association among entities from there types. There are several type of relationship
(i) One to One
(ii) One to Many
(iii) Many to Many
One to One(1:1)
One to one (1:1) relationship is an association only between two entities.
Example in a university each department has only one head of the department. This show one to one relationship between department and the person as head.
One to Many(1:M)
One to many relationship exists when one entity is related to more then one entity. For example a father may have many children but a child has one father.
Many to Many(M:M)
A many to many (M: M) relationship describe entities that may have many relationship among each other. For example one customer may buy many items and one item may be bought by many customers.
Key Attributes:
The key attributes is an attribute that uniquely identifies an entity in the entity set.
Weak Entity & Strong Entity
Entity types that do not have key attributes of their own are called weak entity type. In contrast, regular entity type which have a key attributes are some time called strong entity.
Entity belongs to a weak entity type identified by being related to specific entities from strong type.
What is Class?
A set of object that shares a common structure and a common behavior is called class.
What is Object?
Object is something which is capable of being seen, touched or sensed.