0% found this document useful (0 votes)
39 views

Datamodels

The E-R model is used to design databases and includes entities, attributes, and relationships. Entities have attributes that describe their properties. Relationships define associations between entities. Cardinalities specify the number of entities that can participate in a relationship, such as one-to-one, one-to-many, many-to-one, and many-to-many. Participation constraints define whether an entity must or may participate in a relationship. Keys uniquely identify entities and relationships have degrees defined by the number of participating entity sets.

Uploaded by

]shara
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

Datamodels

The E-R model is used to design databases and includes entities, attributes, and relationships. Entities have attributes that describe their properties. Relationships define associations between entities. Cardinalities specify the number of entities that can participate in a relationship, such as one-to-one, one-to-many, many-to-one, and many-to-many. Participation constraints define whether an entity must or may participate in a relationship. Keys uniquely identify entities and relationships have degrees defined by the number of participating entity sets.

Uploaded by

]shara
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 47

E-R Model

• ER Model is based on:


Entities and their attributes
Relationships among
entities

1
E-R Model components
• Entity: An entity in ER Model is real world entity,
which has some properties called attributes.
Every attribute is defined by its set of values,
called domain or range. For example, in a school
database, a student is considered as an entity.
Student has various attributes like name, age and
class etc.
• An entity set is a collection of similar types of
entities. For example, Students set may contain
all the student of a school.
2
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.
• We can classify attributes as following:
¨ Simple
¨ Composite
¨ Single-valued
¨ Multi-valued
¨ Derived
3
• Attribute(s):
Attributes are the properties which define the entity type. For example,
Roll_No, Name, DOB, Age, Address, Mobile_No are the attributes
which defines entity type Student. In ER diagram, attribute is
represented by an oval.

• Key Attribute
The attribute which uniquely identifies each entity in the entity set is
called key attribute.For example, Roll_No will be unique for each
student. In ER diagram, key attribute is represented by an oval with
underlying lines.

4
• Multivalued Attribute –
An attribute consisting more than one value for a given entity. For example,
Phone_No (can be more than one for a given student). In ER diagram,
multivalued attribute is represented by double oval.

• Derived Attribute –
An attribute which can be derived from other attributes of the entity type is
known as derived attribute. e.g.; Age (can be derived from DOB). In ER
diagram, derived attribute is represented by dashed oval.

5
• CompositeAttribute
An attribute composed of many other attribute is called as composite
attribute. For example, Address attribute of student Entity type
consists of Street, City, State, and Country. In ER diagram, composite
attribute is represented by an oval comprising of ovals.

6
The complete entity type Student with its
attributes can be represented as:

7
E-R Model: Symbols and notations

8
E-R Model: Symbols and notations

9
E-R Model
• Relationship: The association among entities
is called relationship. For example, employee
entity has relation works_at with department.
• Relationships are mapped with entities in
various ways. Mapping cardinalities define
the number of association between two
entities.

10
Constraints
• Various types of constraints
are:
1. Mapping cardinalities
2. Participation constraints
3. Keys

11
Quiz
An ________ is a set of entities of the same type that
share the same properties, or attributes.

a) Entity set
b) Attribute set
c) Relation set
d) Entity model

12
Quiz
Entity is a _________

a) Object of relation
b) Present working model
c) Thing in real world
d) Model of relation

13
Keys
• The key is defined as the column or of the database
• attribute table.
They are used to establish and identify relation between tables.
• They also ensure that each record within a table can be uniquely identified
by combination of one or more fields within a table.

Types of Keys
1. Candidate key : An attribute (or set of attributes) that uniquely identifies a row.
Candidate Key is a super key with no repeated attributes.

14
Key
s

15
Keys
Super Key- An attribute (or combination of attributes) that
uniquely identifies each row in a table. It is a super set of candidate
key.
Example- Consider a student relation having attributes (RollNo,
Name, Class)
Here, RollNo is unique.
Therefore, the super keys will be
1. RollNo
2. RollNo, Name
3. RollNo, Class
4. RollNo, Name, Class
Types of Keys
3. Primary key : is the candidate key which is selected as the principal unique
identifier. It is a key that uniquely identify each record in the table. Cannot contain
null entries.

4. Composite Key: Key that consist of two or more attributes that


uniquely identifies an entity occurrence is called composite key.

17
Types of Keys
5. Foreign Key: A foreign key is generally a primary key from one table that
appears as a field in another where the first table has a relationship to the
second.
In other words, if we had a table A with a primary key X that linked to a table B
where X was a field in B, then X would be a
foreign key in B.

18
Example

19
Difference between Primary and Candidate Key:

20
Quiz

The attribute name could be structured as an attribute


consisting of first name, middle initial, and last name.
This type of attribute is called

a) Simple attribute
b) Composite attribute
c) Multivalued attribute
d) Derived attribute

21
Quiz

The attribute AGE is calculated from DATE_OF_BIRTH.


The attribute AGE is

a) Single valued
b) Multi valued
c) Composite
d) Derived

22
Quiz

Which of the following can be a multivalued attribute?

a) Phone_number
b) Name
c) Date_of_birth
d) All of the mentioned

23
Mapping Cardinalities
• Mappin cardinalit or cardinality ratios
g the
y , entities
of to
entity
express number associated via
be which
relationship
another can set a
• Mapping
cardinalities:
– one to one
– one to many
– many to one
– many to many
24
• One-to-one: one entity from entity set A can associated with at
be most one entity of entity set B and vice
versa.

25
• One-to-many: One entity from entity set A can be associated more than one entities
of entity set B but from entity set B one entity can be associated with at most one
entity.

26
• Many-to-one: More than one entities from entity set A
can be associated with at most one entity of entity set B
but one entity from entity set B can be associated with
more than one entity from entity set A.

27
• Many-to-many: one entity from A can be associated with more than one
entity from B and vice versa.

28
Quiz

An entity in A is associated with at most one entity in B,


and an entity in B is associated with at most one entity in
A. This is called as

a) One-to-many
b) One-to-one
c) Many-to-many
d) Many-to-one

29
Quiz

An entity in A is associated with at most one entity in B,


and an entity in B is associated with at most one entity in
A. This is called as

a) One-to-many
b) One-to-one
c) Many-to-many
d) Many-to-one

30
Participation Constraints
• The participation of an entity set E in a
relationship set R is said to be total if every
entity in E participates in at least one
relationship in R.
• If only some entities in E participate in
relationships in R, the participation is said to
be partial.

31
Example

Total participation of Loan


entity
32
Degree of Relationship Set
The number of different entity sets participating in a relationship
set is called as degree of a relationship set.

• Unary Relationship – When there is only ONE entity set


participating in a relation, the relationship is called as unary
relationship.

33
Degree of Relationship Set
• Binary Relationship – When there are TWO entities set
participating in a relation, the relationship is called as binary
relationship. For example, Student is enrolled in Course.

34
Degree of Relationship Set
• Ternary Relationship – When there are three entities set
participating in a relation, the relationship is called as ternary
relationship.

• n-ary Relationship –When there are n entities set participating


in a relation, the relationship is called as n-ary relationship.

35
Quiz

A person name, birthday and social security number are


all examples of _______?

A). Entities
B). Attributes
C). Relationships
D). Descriptors

36
Quiz

In an E-R diagram a relationship is represented


by________?

A). Ellipse
B). Rectangle
C). Diamond

37
Strong and Weak entity sets
• The entity set which does not have sufficient attributes
to form a primary key is called a Weak entity set.
• The entity set which has the primary key is called as
Strong entity set.
• A member of a strong entity set is called dominant
entity and member of a weak entity set is called
subordinate entity.
• Weak entity does not have a primary key but we need
a mean to distinguish among other entities. The
discriminator of a weak entity set is a set of attributes
that allows this distinction to be made. Ex:
payment_number.

38
Example

39
Quiz

An entity type whose existence depends on another


entity type is called _________ entity?

A). Strong
B). Weak
C). Dependent
D). Variant

40
Steps in designing E-R Diagram
• There are following steps:
– Identify the entities from the requirement
sheets
– Find relationships among those entities
– Identify the key attributes for every entity
– Identify other relevant attributes
– Draw complete E-R diagram with all
attributes including Primary key
– Review your results with your Business users

41
Example: University Management
System

42
Example: Hospital Management System

43
Example

44
E-R Diagram

45
Generalization and Specialization
Generalization
Generalization is a process of generalizing an entity which contains generalized
attributes or properties of generalized entities. The entity that is created will
contain the common features. Generalization is a Bottom up process.
We can have three sub entities as Car, Truck, Motorcycle and these three entities
can be generalized into one general super class as Vehicle.

46
Generalization and Specialization
Specialization

Specialization is a process of identifying subsets of an entity that shares different


characteristics. It breaks an entity into multiple entities from higher level (super
class) to lower level (sub class). The breaking of higher level entity is based on
some distinguishing characteristics of the entities in super class.
It is a top down approach in which we first define the super class and then sub
class and then their attributes and relationships.

47

You might also like