Data Models ER Updated

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 28

Data Models

ER Data Model

http://www.tutorialspoint.com/dbms/
ER model -- Database Modeling
• The ER data mode was developed to facilitate database design by allowing
specification of an enterprise schema that represents the overall logical
structure of a database.
• The ER model is very useful in mapping the meanings and interactions of real-
world enterprises onto a conceptual schema. Because of this usefulness, many
database-design tools draw on concepts from the ER model.
• The ER data model employs three basic concepts:
– entity sets,
– relationship sets,
– attributes.
• The ER model also has an associated diagrammatic representation, the ER
diagram, which can express the overall logical structure of a database
graphically.
Entity Sets
• An entity is an object that exists and is distinguishable from other objects.
– Example: specific person, company, event, plant

• An entity set is a set of entities of the same type that share the same
properties.
– Example: set of all persons, trees, holidays
• An entity is represented by a set of attributes; i.e., descriptive properties
possessed by all members of an entity set.
– Example:
instructor = (ID, name, street, city, salary )
course= (course_id, title, credits)
• A subset of the attributes form a primary key of the entity set; i.e., uniquely
identifying each member of the set.
Entity Sets -- instructor and student

instructor_ID instructor_name student-ID student_name


Complex Attributes
• Attribute types:
– Simple and composite attributes.
– Single-valued and multivalued attributes
• Example: multivalued attribute: phone_numbers
– Derived attributes
• Can be computed from other attributes
• Example: age, given date_of_birth
• Domain – the set of permitted values for each attribute
Composite Attributes
Weak Entity Sets
• Consider a section entity, which is uniquely identified by a course_id,
semester, year, and sec_id.
• Clearly, section entities are related to course entities. Suppose we create a
relationship set sec_course between entity sets section and course.
• Note that the information in sec_course is redundant, since section already
has an attribute course_id, which identifies the course with which the
section is related.
• One option to deal with this redundancy is to get rid of the relationship
sec_course; however, by doing so the relationship between section and
course becomes implicit in an attribute, which is not desirable.
Weak Entity Sets (Cont.)
• An alternative way to deal with this redundancy is to not store the attribute course_id
in the section entity and to only store the remaining attributes section_id, year, and
semester. However, the entity set section then does not have enough attributes to
identify a particular section entity uniquely; although each section entity is distinct,
sections for different courses may share the same section_id, year, and semester.
• To deal with this problem, we treat the relationship sec_course as a special relationship
that provides extra information, in this case, the course_id, required to identify section
entities uniquely.
• The notion of weak entity set formalizes the above intuition. A weak entity set is one
whose existence is dependent on another entity, called its identifying entity; instead of
associating a primary key with a weak entity, we use the identifying entity, along with
extra attributes called discriminator to uniquely identify a weak entity. An entity set
that is not a weak entity set is termed a strong entity set.
Weak Entity Sets (Cont.)
• Every weak entity must be associated with an identifying entity; that
is, the weak entity set is said to be existence dependent on the
identifying entity set. The identifying entity set is said to own the
weak entity set that it identifies. The relationship associating the
weak entity set with the identifying entity set is called the
identifying relationship.
• Note that the relational schema we eventually create from the entity
set section does have the attribute course_id, for reasons that will
become clear later, even though we have dropped the attribute
course_id from the entity set section.
E-R Diagrams Notaions-1
E-R Diagram
• Entity relationship model defines the conceptual view of
database.
• It works around real world entity and association among
them.

http://www.tutorialspoint.com/dbms/
Entity

• A real-world thing either animate or inanimate that can be


easily identifiable and distinguishable.
• For example, in a school database, student, teachers, class and course
offered can be considered as entities
• An entity set is a collection of similar types of entities. Entity
set may contain entities with attribute sharing similar values.

http://www.tutorialspoint.com/dbms/
Attributes

• Entities are represented by means of their properties, called


attributes.
– For example, a student entity may have name, class, age as
attributes.

http://www.tutorialspoint.com/dbms/
http://www.tutorialspoint.com/dbms/
Types of attributes:
• Simple attribute:
• Simple attributes are atomic values, which cannot be divided further.
– For example, 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 attributes, which do not exist physical in the database, but there
values are derived from other attributes presented in the database.
– For example, average_salary in a department should be saved in database instead it can be
derived.
– For another example, age can be derived from data_of_birth.

http://www.tutorialspoint.com/dbms/
• Single-valued attribute:
• Single valued attributes contain on single value.
– For example: Social_Security_Number.
• Multi-value attribute:
• Multi-value attribute may contain more than one values.
– For example, a person can have more than one phone numbers,
email_addresses etc.

http://www.tutorialspoint.com/dbms/
http://www.tutorialspoint.com/dbms/
Relationship

• The association among entities is called relationship.


– For example, employee entity has relation works_at with department
• Relationship Set:
• Relationship of similar type is called relationship set.

• Degree of relationship
• The number of participating entities in an relationship defines the degree of the
relationship.
• Binary = degree 2
• Ternary = degree 3
• n-ary = degree

http://www.tutorialspoint.com/dbms/
ER Diagram Representation

• Entity
• Entities are represented by means of rectangles. Rectangles
are named with the entity set they represent.

http://www.tutorialspoint.com/dbms/
• Attributes

http://www.tutorialspoint.com/dbms/
relationship and cardinality

• One-to-one
• When only one instance of entity is associated with the
relationship, it is marked as '1'. This image below reflects that
only 1 instance of each entity should be associated with the
relationship. It depicts one-to-one relationship.

http://www.tutorialspoint.com/dbms/
• One-to-many
• When more than one instance of entity is associated with the relationship, it is
marked as 'N'. This image below reflects that only 1 instance of entity on the left
and more than one instance of entity on the right can be associated with the
relationship. It depicts one-to-many relationship.

http://www.tutorialspoint.com/dbms/
• Many-to-one
• When more than one instance of entity is associated with the
relationship, it is marked as 'N'. This image below reflects that more
than one instance of entity on the left and only one instance of entity
on the right can be associated with the relationship. It depicts many-
to-one relationship

http://www.tutorialspoint.com/dbms/
• Many-to-many
• This image below reflects that more than one instance of entity on the
left and more than one instance of entity on the right can be
associated with the relationship. It depicts many-to-many relationship.

http://www.tutorialspoint.com/dbms/
Participation Constraints

• Total Participation: Each entity in the entity is involved in the


relationship. Total participation is represented by double
lines.
• Partial participation: Not all entities are involved in the
relation ship. Partial participation is represented by single
line.

http://www.tutorialspoint.com/dbms/
Generalization Aggregation

• In generalization, a number of entities are brought together


into one generalized entity based on their similar
characteristics. For an example, pigeon, house sparrow, crow
and dove all can be generalized as Birds

http://www.tutorialspoint.com/dbms/
Specialization
• Specialization is a process, which is
opposite to generalization, as mentioned
above. In specialization, a group of entities
is divided into sub-groups based on their
characteristics.
• In a company, a person can be identified
as employee, employer, customer or
vendor based on what role do they play in
company.

http://www.tutorialspoint.com/dbms/
Inheritance

• The important features of


Generalization and Specialization, is
inheritance, that is, the attributes of
higher-level entities are inherited
by the lower level entities.

http://www.tutorialspoint.com/dbms/

You might also like