Lecture 3
Lecture 3
Lecture 3
[email protected]
DATABASE DESIGN
• Creating a database application involves the following activities:-
• The needs of the users always play a central role in the design process.
DATABASE DESIGN…
Design Phases
• Initial phase
Initial phase
o Example
▪ modifying or updating data
▪ searching for and retrieving specific data
▪ deleting data
DATABASE DESIGN…
Design Phases
✓relationships
DATABASE DESIGN…
Design Phases
• Redundancy
✓leads to inconsistency
• Incompleteness
✓Relational model
ENTITY-RELATIONSHIP (E-R) MODEL
• E-R model is a graphical approach to database design that shows
how entities are related to each other.
• Example:
✓students of colleges and schools
✓loans in banks
✓employees in a company
ENTITY-RELATIONSHIP (E-R) MODEL
Terminologies
Attributes/properties
• These are the characteristics of any entity.
• Example:
1. A student can be described by his/her student id, name, age,
address, height, class
2. Loans can be described by their types such as house loan, car loan
3. Employees in a company can be described by their Employee ID,
name, department, designation
ENTITY-RELATIONSHIP (E-R) MODEL
Terminologies
Value
• Value is the information or data which is stored in attributes of any
entity.
• Example:
attribute value
student_id 0001
name Clatous
age 30
address Mbezi
ENTITY-RELATIONSHIP (E-R) MODEL
Terminologies
Entity Sets
• All the entities having same attributes make an entity set.
• Composite attribute
• An attribute that can be divided into subparts.
• Example: name of a student can be divided into first name, middle
name and last name.
TYPES OF ATTRIBUTES
Attributes can be characterized by the following types:
2. Single Valued and Multi-valued Attributes
• Single valued attribute
• An attribute having only single value for a particular entity.
• Example: age of a student.
• Multi-valued attribute
• An attribute having more than one possible value for a particular
entity is known as multi-valued attribute.
• Example: phone number of a student. A student may have more than
one phone number.
TYPES OF ATTRIBUTES
Attributes can be characterized by the following types:
3. Derived Attributes and Stored Attributes
• Derived Attribute
• An attribute that can be derived from other known attributes.
• The value of a derived attribute is not stored but is computed when
required.
• Example: Age of an employee can be derived if you know date of
birth and system date.
• Stored Attribute
• An attribute which cannot be derived by other known attributes.
• Example: Date of birth of any employee.
RELATIONSHIP
• A relationship refers to the association among several entities.
• Example:
✓ a relationship advisor that associates instructor Samwel with student Hamida.
RELATIONSHIP…
• A relationship set is a set of relationships of same type.
• This rectangle is linked to the diamond representing that relationship set with
a dashed line.
Descriptive attribute
RELATIONSHIP…
Degree of relationship sets
• Refers to the total number of entity sets participating in a relationship set.
e1
r1
e2
r2 e1
e3
r3 e3
e4
r4
e5
RELATIONSHIP…
Binary Relationship Set
• A relationship set where only two entity sets participates in a
relationship set (degree 2).
RELATIONSHIP…
Ternary Relationship Set
• A relationship set in which three entity sets participates in a
relationship set (degree 3).
RELATIONSHIP…
• A role of an entity refers to a function that entity plays in a relationship.
• Example
An employee plays the role of worker in his/her department
• A recursive relationship set refers to a situation when the same entity sets
participate in same relationship set more than once with different roles
each time.
• Example
A manager (employee) supervises a subordinate (employee).
MAPPING CARDINALITIES
(CARDINALITY RATIOS)
• Mapping cardinalities refers to the number of entities to which another
entity can be associated via a relationship set.
• Types of cardinalities
• One to One (1 : 1)
• One to Many (1 : N)
• Many to One (N : 1)
• Many to Many (M : N)
MAPPING CARDINALITIES
(CARDINALITY RATIOS)
One to One (1 : 1)
• An entity in table X is associated with at most one entity in table Y and an
entity in table Y is associated with at most one entity in table X.
• Example
MAPPING CARDINALITIES
(CARDINALITY RATIOS)
One to Many (1 : N)
• An entity in table X is associated with any number of entities in table Y. An
entity in table Y is associated with at most one entity in table X.
• Example
MAPPING CARDINALITIES
(CARDINALITY RATIOS)
Many to One (N : 1)
• An entity in table X is associated with at most one entity in table Y. An entity
in table Y is associated with any number of entities in table X.
• Example
MAPPING CARDINALITIES
(CARDINALITY RATIOS)
Many to Many (M : N)
• An entity in table X is associated with any number of entities in table Y and
vice versa.
• Example
Successful and unsuccessful people
do not vary greatly in their abilities.
They vary in their desires to reach
their potential. –
John Maxwell