This document provides an overview of entity-relationship (ER) models, which allow specification of a database schema representing the logical structure of a database. It discusses key concepts including entity sets, relationship sets, attributes, and mapping constraints. Entity sets represent collections of real-world objects or concepts that share common properties. Relationship sets define associations between entity sets. Attributes provide additional information about entities. Mapping constraints specify cardinality ratios for relationships. The document also covers ER diagramming and the differences between weak and strong entities.
3. Introduction
➢The entity-relationship(E-R) data model was develop to
facilitate database design by allowing specification of an
enterprise schema that represents the overall logical structure
of a database:
➢ The ER data model employees three basic concepts:
1)Entity Set
2)Relationship Set and,
3)Attributes
4. Entity Set
A database can be modeled as:
1. A collection of entities,
2. Relationship among entities.
An entity is an object that exist and is distinguishable from
other objects.
Example: Specific person , company, event, plant
Entity have attributes
Example: People have name and address
An entity set is a set of entities of the same type that share
same properties .
Example : set of all persons, companies, trees, holidays
5.
6. Relationship set
A relation is an association among several entities
In above example we can see there are two entities instructor and student
In the example instructor provide instructions to the student
7. Attributes
➢ An attribute of an entity set is a function that maps from the entity set
into a domain.
➢ Domain: the set of permitted values for each attribute.
➢ Attribute Type:
1. Simple and composite attributes
2. Single-valued and multi-valued attributes.
Example: Multivalued attributes: phone no.
3.Derived Attributes
Can be computed from other attributes
E.G. age, given date of birth
8. Mapping Constraint
➢ Mapping cardinalities, or cardinality ratio, express the number
of entities to which another entity can be associated via a
relationship set.
➢ For a binary relationship set the mapping cardinality must be
one of the following types:
1.One-to-one
2.One-to-many
3.Many-to-one
4.Many-to-many
9. One-to-one
➢ An entity is A, is associated with at most one entity in B, and entity B is
associated with at most one entity in A.
Example:-
10. One-to-many
➢ An entity is A is associated with any number(Zero or more) of
entities in B. an entity in B, however, can be associated with at
most one entity in A.
Example:-
11. Many-to-one
➢ An entity in A is associated with at most one entity in B. An
entity in B, however, can be associated with at most one entity in
any number(Zero or more) of entities in A.
Example:-
12. Many-to-many
➢ An entity in A is associated with any number(Zero or more) of
entities in B. And an entity in B is associated with at most one entity
in any number (Zero or more) of entities in A.
Example:-
13. Keys
We must have a way to specify how entities within a given set are
distinguished.
Keys are very important part of Relational database model. They
are used to establish and identify relationships between tables and
also to uniquely identify any record or row of data inside a table.
14. Primary key
➢ Primary key is a candidate key that is most appropriate to become
the main key for any table. It is a key that can uniquely identify
each record in a table.
15. Candidate Key
Candidate keys are defined as the minimal set of fields which can
uniquely identify each record in a table. It is an attribute or a set of
attributes that can act as a Primary Key for a table to uniquely
identify each record in that table.
17. Foreign Key
A Foreign ket in one table points to a primary key in another table
A foreign kay can have a different name than the primary key it comes
from.
The primary key used by a foreign key is also known as a parent key.
Foreign key value can be null, even though primary key value can’t
Foreign key don’t have to be unique in fact, they often aren’t
18. ER Diagram
➢ An entity relationship diagram (ERD), also known as an entity
relationship model, is a graphical representation of an information
system that depicts the relationships among people, objects, places,
concepts or events within that system.