DB Ex1
DB Ex1
Entity relationship data model allows us to o describe the data involved in a real world
enterprise in terms of objects and their relationships and is widely used to develop an initial
database design.
It is a graphical user representation of the logical structure of database.
It helps you to identify the entities which exist in a system and the relationships between those
entities.
ER diagrams can be used by database designers as a blueprint for implementing data in specific
software applications
The database designer gains a better understanding of the information to be contained in the
database with the help of ERP diagram
ERD is allowed you to communicate with the logical structure of the database to users
Entity:
An entity is a thing or object in the real world that is distinguishable from all other objects.
An entity can be place, person, object, event or a concept, which stores data in the database.
Examples of entities:
Person: Employee, Student, Patient
Place: Store, Building
Object: Machine, product, and Car
Event: Sale, Registration, Renewal
Concept: Account, Course
Entity set:
An entity set is a set of entities of the same type that share the same properties.
Example: set of all persons, companies, trees, holidays.
Attributes:
Entities are represented by means of their properties, called attributes. All attributes have values.
Example: a student entity may have name, class, age as attributes.
There exits domain range values that can be assigned to attributes.
Example: a student’s name cannot be a numeric value. It has to be alphabetic. A student’s
age cannot be negative, etc.
Simple attribute – Simple attributes are atomic values, which cannot be divided further. For
example, a student’s phone number is an atomic value of 10 digits.
Composite attribute – Composite attributes are made of more than one simple attribute. For
example, a student’s complete name may have first_name and last_name.
Derived attribute – Derived attributes are the attributes that do not exist in the physical database,
but their values are derived from other attributes present in the database. For example,
average_salary in a department should not be saved directly in the database, instead it can be
derived. For another example, age can be derived from data_of_birth.
Single-value attribute – Single value attributes contain single value. For example –
social_Security_Number.
Multivalued attribute – Multivalued attributes may contain more than one values. For example,
a person can have more than one phone number, email_address, etc.
Key: Key is an attribute or collection of attributes that uniquely identifies an entity among entity
set. For example, the roll_number of a student makes him/her identifiable among students.
There are mainly three types of keys:
Super Key − A set of attributes (one or more) that collectively identifies an entity in an entity set.
Candidate Key − A minimal super key is called a candidate key. An entity set may have more
than one candidate key.
Primary Key − A primary key is one of the candidate keys chosen by the database designer to
uniquely identify the entity set.
Relationship:
Relationship is nothing but an association among two or more entities. E.g., Tom works in the
Chemistry department.
Relationship Set: A set of relationships of similar type is called a relationship set. Like entities, a
relationship too can have attributes. These attributes are called descriptive attributes.
Degree of Relationship: The number of participating entities in a relationship defines the degree
of the relationship.
Mapping Cardinalities
Cardinality defines the number of entities in one entity set, which can be associated with the
number of entities of other set via relationship set.
Types of Cardinalities
One-to-one: One entity from entity set A can be associated with at most one entity of entity set B
and vice versa.
One-to-many: One entity from entity set A can be associated with more than one entities of entity
set B however an entity from entity set B, can be associated with at most one entity
Many to One: More than one entities from entity set A can be associated with at most one entity
of entity set B, however an entity from entity set B can be associated with more than one entity
from entity set A.
Many to Many: One entity from A can be associated with more than one entity from B and vice
versa.
ER- Diagram Symbols / Notations
Entity
Weak Entity
Relationship
Multivalued Attribute
Derived Attribute
Weak Relationships
Key Attributes
One-to-one association
One-to-many association
Many-to-Many association