E-R MODEL
Entities
■ An entity is an object whose information is stored in the database. It is distinguishable from other
objects.
■ For example: specific person, company, event, plant.
■ In other words, any thing that may ‘have an independent existence and about which we intend to
collect data is known as Entity. It is also known as Entity type.
■ Entities are the principal data object about which information is to be collected. Entities are usually
recognizable concepts, either concrete or abstract, such as person, places, things, or events, which
have relevance to the database.
■ Some specific examples of entities are EMPLOYEES, PROJECTS, and INVOICES.An entity is
analogous to a table in the relational model. Entities are classified as independent or dependent (in
some methodologies, the terms used are strong and weak, respectively).
■ An independent entity is one that does not rely on another for identification.A dependent entity is
one that relies on another for identification.An entity occurrence (also called an instance) is an
individual occurrence of an entity. An occurrence is analogous to a row in the relational table.
Attributes
■ Attributes describe the properties of the entity of which they are associated.A particular instance of
an attribute is a value.
■ For example, “Ram” is one value of the attribute Name.The domain of an attribute is the collection
of all possible values an attribute can have.The domain of Name is a character string.
■ We can classify attributes as following types:
■ • Simple
■ • Composite
■ • Single-values
■ • Multi-values
■ • Derived
■ Simple Attribute:A simple attribute is an attribute composed of a single component with an
independent existence. Simple attributes cannot be further subdivided. Examples of simple
attributes include Sex,Age, and Salary etc. Simple attributes are sometimes called atomic
attributes.
■ Composite Attribute: An attribute composed of multiple components, each with an independent
existence is called a composite attribute. Some attributes can be further divided to yield smaller
components with an independent existence of their own.
■ For example, the Address attribute can be composed of components like Street number, Area, City,
Pin code and so on.The decision to model the Address, Area, and City etc. is dependent on whether
the user view of the model refers to the Address attribute as a single unit or as individual
components.
■ Single-valuedAttribute: A single-valued attribute is one that holds a single value for a single entity.
The majority of attributes are single-valued for a particular entity. For example, the Classroom entity
has as single value for the room_number attribute and therefore the room_number attribute is
referred to as being single-valued.
■ Multi-valuedAttribute: A multi-valued attribute is one that holds multiple values for a single
entity. Some attribute has multiple values for a particular entity. For example, a student entity can
have multiple values for the Hobby attribute-reading, music, movies and so on.A multi-valued
attribute may have set of numbers with upper and lower limits.
■ For example, the Hobby attribute of a Student may have between one and five values. In other
words, a student may have a minimum of one hobby and maximum of 5 hobbies.
■ DerivedAttribute: A derived attribute is one that represents a value that is derivable from the
value of a related attribute or set of attributes, not necessarily in the same entity. Some attributes
may be related for a particular entity.
■ For example the Age attribute can be derived from the date-of-birth attribute and therefore they
are related.We refer the age attribute as a derived attribute, the value of which is derived from
the date-of-birth attribute.
Diagrams of Attributes
Diagram of Multivalued and Derived
Attribute
■ MultivaluedAttribute
■ DerivedAttribute
Relationships
■ A Relationship represents an association between two or more entities. Relationships are classified in
terms of degree, connectivity, cardinality, and existence.
■ An example of a relationship would be: • Employees are assigned to projects • Projects have subtasks
• Departments manage one or more projects
■ Degree of a Relationship
■ The degree of a relationship is the number of entities associated with the relationship.The n-
ary relationship is the general form for degree n. Special cases are the binary, and ternary, where the
degree is 2, and 3, respectively. Binary relationships, the association between two entities are the
most common type in the real world.A recursive binary relationship occurs when an entity is related
to itself.
■ An example might be “some employees are married to other employees”. A ternary relationship
involves three entities and is used when a binary relationship is inadequate. Many modeling
approaches recognize only binary relationships.Ternary or n-ary relationships are decomposed into
two or more binary relationships.
Keys
■ A key is an attribute of a table which helps to identify a row.There can be many different types of
keys which are explained here.
■ Super Key or Candidate Key: It is such an attribute of a table that can uniquely identify a row in a
table. Generally they contain unique values and can never contain NULL values.There can be more
than one super key or candidate key in a table e.g. within a STUDENT table Roll and Mobile No. can
both serve to uniquely identify a student.
■ Primary Key: It is one of the candidate keys that are chosen to be the identifying key for the entire
table. E.g. although there are two candidate keys in the STUDENT table, the college would obviously
use Roll as the primary key of the table.
■ Alternate Key: This is the candidate key which is not chosen as the primary key of the table.They
are named so because although not the primary key, they can still identify a row.
■ Composite Key: Sometimes one key is not enough to uniquely identify a row. E.g. in a single class
Roll is enough to find a student, but in the entire school, merely searching by the Roll is not
enough, because there could be 10 classes in the school and each one of them may contain a
certain roll no 5.To uniquely identify the student we have to say something like “classVII, roll no 5”.
So, a combination of two or more attributes is combined to create a unique combination of values,
such as Class + Roll.
■ Foreign Key: Sometimes we may have to work with an attribute that does not have a primary key
of its own.To identify its rows, we have to use the primary attribute of a related table. Such a copy
of another related table’s primary key is called foreign key
■ Strong andWeak Entity Based on the concept of foreign key, there may arise a situation when we
have to relate an entity having a primary key of its own and an entity not having a primary key of
its own. In such a case, the entity having its own primary key is called a strong entity and the entity
not having its own primary key is called a weak entity.
■ Whenever we need to relate a strong and a weak entity together, the ERD would change just a
little. Say, for example, we have a statement “A Student lives in a Home.”
■ STUDENT is obviously a strong entity having a primary key Roll. But HOME may not have a unique
primary key, as its only attribute Address may be shared by many homes (what if it is a housing
estate?). HOME is a weak entity in this case.
■ The ERD of this statement would be like the following.As you can see, the weak entity itself and
the relationship linking a strong and weak entity must have double border.
How to Draw ER Diagrams
■ Below points show how to go about creating an ER diagram.
 Identify all the entities in the system. An entity should appear only once in a particular
diagram. Create rectangles for all entities and name them properly.
 Identify relationships between entities. Connect them using a line and add a diamond in the
middle describing the relationship.
 Add attributes for entities. Give meaningful attribute names so they can be understood easily.
E-R Diagram Symbols and their meaning
E-R model for employee table
Exercises
1. Construct an ER diagram for a car-insurance company whose customers own one
or more cars each. Each car has associated with it zero to any number of recorded
accidents.
2. Construct an ER diagram for a hospital with a set of patients and a set of doctors.
Associate with each patient a log of the various tests and examinations conducted.
3. Construct an ER diagram of the library system in your college.
Librarian
password
Issue
4. Construct an ER diagram to maintain data about students, instructors, semester,
and courses in a college.
5. Construct an ERD to record the marks that students get in different exams of
different course offerings.

Er diagram

  • 1.
  • 2.
    Entities ■ An entityis an object whose information is stored in the database. It is distinguishable from other objects. ■ For example: specific person, company, event, plant. ■ In other words, any thing that may ‘have an independent existence and about which we intend to collect data is known as Entity. It is also known as Entity type. ■ Entities are the principal data object about which information is to be collected. Entities are usually recognizable concepts, either concrete or abstract, such as person, places, things, or events, which have relevance to the database. ■ Some specific examples of entities are EMPLOYEES, PROJECTS, and INVOICES.An entity is analogous to a table in the relational model. Entities are classified as independent or dependent (in some methodologies, the terms used are strong and weak, respectively). ■ An independent entity is one that does not rely on another for identification.A dependent entity is one that relies on another for identification.An entity occurrence (also called an instance) is an individual occurrence of an entity. An occurrence is analogous to a row in the relational table.
  • 3.
    Attributes ■ Attributes describethe properties of the entity of which they are associated.A particular instance of an attribute is a value. ■ For example, “Ram” is one value of the attribute Name.The domain of an attribute is the collection of all possible values an attribute can have.The domain of Name is a character string. ■ We can classify attributes as following types: ■ • Simple ■ • Composite ■ • Single-values ■ • Multi-values ■ • Derived
  • 4.
    ■ Simple Attribute:Asimple attribute is an attribute composed of a single component with an independent existence. Simple attributes cannot be further subdivided. Examples of simple attributes include Sex,Age, and Salary etc. Simple attributes are sometimes called atomic attributes. ■ Composite Attribute: An attribute composed of multiple components, each with an independent existence is called a composite attribute. Some attributes can be further divided to yield smaller components with an independent existence of their own. ■ For example, the Address attribute can be composed of components like Street number, Area, City, Pin code and so on.The decision to model the Address, Area, and City etc. is dependent on whether the user view of the model refers to the Address attribute as a single unit or as individual components. ■ Single-valuedAttribute: A single-valued attribute is one that holds a single value for a single entity. The majority of attributes are single-valued for a particular entity. For example, the Classroom entity has as single value for the room_number attribute and therefore the room_number attribute is referred to as being single-valued.
  • 5.
    ■ Multi-valuedAttribute: Amulti-valued attribute is one that holds multiple values for a single entity. Some attribute has multiple values for a particular entity. For example, a student entity can have multiple values for the Hobby attribute-reading, music, movies and so on.A multi-valued attribute may have set of numbers with upper and lower limits. ■ For example, the Hobby attribute of a Student may have between one and five values. In other words, a student may have a minimum of one hobby and maximum of 5 hobbies. ■ DerivedAttribute: A derived attribute is one that represents a value that is derivable from the value of a related attribute or set of attributes, not necessarily in the same entity. Some attributes may be related for a particular entity. ■ For example the Age attribute can be derived from the date-of-birth attribute and therefore they are related.We refer the age attribute as a derived attribute, the value of which is derived from the date-of-birth attribute.
  • 6.
  • 7.
    Diagram of Multivaluedand Derived Attribute ■ MultivaluedAttribute ■ DerivedAttribute
  • 8.
    Relationships ■ A Relationshiprepresents an association between two or more entities. Relationships are classified in terms of degree, connectivity, cardinality, and existence. ■ An example of a relationship would be: • Employees are assigned to projects • Projects have subtasks • Departments manage one or more projects ■ Degree of a Relationship ■ The degree of a relationship is the number of entities associated with the relationship.The n- ary relationship is the general form for degree n. Special cases are the binary, and ternary, where the degree is 2, and 3, respectively. Binary relationships, the association between two entities are the most common type in the real world.A recursive binary relationship occurs when an entity is related to itself. ■ An example might be “some employees are married to other employees”. A ternary relationship involves three entities and is used when a binary relationship is inadequate. Many modeling approaches recognize only binary relationships.Ternary or n-ary relationships are decomposed into two or more binary relationships.
  • 9.
    Keys ■ A keyis an attribute of a table which helps to identify a row.There can be many different types of keys which are explained here. ■ Super Key or Candidate Key: It is such an attribute of a table that can uniquely identify a row in a table. Generally they contain unique values and can never contain NULL values.There can be more than one super key or candidate key in a table e.g. within a STUDENT table Roll and Mobile No. can both serve to uniquely identify a student. ■ Primary Key: It is one of the candidate keys that are chosen to be the identifying key for the entire table. E.g. although there are two candidate keys in the STUDENT table, the college would obviously use Roll as the primary key of the table.
  • 10.
    ■ Alternate Key:This is the candidate key which is not chosen as the primary key of the table.They are named so because although not the primary key, they can still identify a row. ■ Composite Key: Sometimes one key is not enough to uniquely identify a row. E.g. in a single class Roll is enough to find a student, but in the entire school, merely searching by the Roll is not enough, because there could be 10 classes in the school and each one of them may contain a certain roll no 5.To uniquely identify the student we have to say something like “classVII, roll no 5”. So, a combination of two or more attributes is combined to create a unique combination of values, such as Class + Roll. ■ Foreign Key: Sometimes we may have to work with an attribute that does not have a primary key of its own.To identify its rows, we have to use the primary attribute of a related table. Such a copy of another related table’s primary key is called foreign key
  • 11.
    ■ Strong andWeakEntity Based on the concept of foreign key, there may arise a situation when we have to relate an entity having a primary key of its own and an entity not having a primary key of its own. In such a case, the entity having its own primary key is called a strong entity and the entity not having its own primary key is called a weak entity. ■ Whenever we need to relate a strong and a weak entity together, the ERD would change just a little. Say, for example, we have a statement “A Student lives in a Home.” ■ STUDENT is obviously a strong entity having a primary key Roll. But HOME may not have a unique primary key, as its only attribute Address may be shared by many homes (what if it is a housing estate?). HOME is a weak entity in this case. ■ The ERD of this statement would be like the following.As you can see, the weak entity itself and the relationship linking a strong and weak entity must have double border.
  • 12.
    How to DrawER Diagrams ■ Below points show how to go about creating an ER diagram.  Identify all the entities in the system. An entity should appear only once in a particular diagram. Create rectangles for all entities and name them properly.  Identify relationships between entities. Connect them using a line and add a diamond in the middle describing the relationship.  Add attributes for entities. Give meaningful attribute names so they can be understood easily.
  • 13.
    E-R Diagram Symbolsand their meaning
  • 15.
    E-R model foremployee table
  • 19.
  • 20.
    1. Construct anER diagram for a car-insurance company whose customers own one or more cars each. Each car has associated with it zero to any number of recorded accidents.
  • 21.
    2. Construct anER diagram for a hospital with a set of patients and a set of doctors. Associate with each patient a log of the various tests and examinations conducted.
  • 22.
    3. Construct anER diagram of the library system in your college. Librarian password Issue
  • 23.
    4. Construct anER diagram to maintain data about students, instructors, semester, and courses in a college.
  • 24.
    5. Construct anERD to record the marks that students get in different exams of different course offerings.