The Co-operative University of Kenya: January- April 2026
DATABASE DESIGN
Bro. Dr. Okari
What is Database Design?
▪ Database design is the process of creating a detailed data
model that specifies the structure, format, and organization of
data in a database system
▪ Its purpose is to ensure data is stored efficiently, retrieved
quickly, and maintained consistently.
▪ A well-designed database improves performance, scalability,
and usability of applications.
Stages of Database Design
1. Requirements Analysis
✓ Identify what data needs to be stored and what the system must
achieve.
✓ Example: In a university system, requirements might include storing
student records, courses, and grades.
2. Conceptual Design
✓ High-level representation using Entity-Relationship (ER) diagrams.
✓ Focuses on entities (e.g., Student, Course) and relationships (e.g.,
Enrolls).
Stages of Database Design
3. Logical Design
✓ Converts the conceptual model into a relational schema.
✓ Defines tables, attributes, primary keys, and foreign keys.
✓ Example: Student table with StudId , Name, Email.
4. Physical Design
✓ Implements the logical schema in a specific Database Management
System (DBMS).
✓ Includes indexes, storage structures, and optimization for
performance.
Why Database Design Matters
i. Data Integrity: Prevents duplication and inconsistencies.
ii. Performance: Optimizes queries and storage.
iii. Scalability: Supports growth in data volume and
complexity.
iv. Security: Ensures proper access control and compliance.
1. Requirement Analysis
▪ Also known as pre-design stage
▪ Its purpose is to understand what the organization or system
actually needs from the database.
▪ Activities:
✓ Interview stakeholders, users, and managers.
✓ Collect business rules and processes.
✓ Identify what data must be stored, how it will be used,
and what constraints exist.
1. Requirement Analysis…
Example:
▪ In a university system, requirement analysis might reveal:
➢ Store student details (ID, name, email).
➢ Track courses offered (course code, title, credits).
➢ Record which students enroll in which courses.
➢ Capture instructors teaching courses.
▪ Output: A clear list of requirements and business rules, often
documented in text form.
2. Conceptual Design
▪ It is the first formal stage
▪ Translate requirements into a high-level data model.
▪ Activities: Identify entities, attributes, and relationships.
▪ Example: Draw an E-R diagram showing Student, Course,
Lecturer, and Enrollment.
Entity-Relationship (E-R) Model
▪ The Entity-Relationship Model (ER Model) is a conceptual model for
designing a database.
▪ This model represents the logical structure of a database, including
entities, their attributes, and relationships between them.
i. Entity: An object that is stored as data.
E.g: Student, Course, or Company.
ii. Attribute: Properties that describe an entity.
E.g: StudentID, CourseName, or EmployeeEmail.
iii. Relationship: A connection between entities. E.g: Student enrolls in
a Course.
✓ The graphical representation of this model is called an Entity-Relationship
Diagram (ERD)
The E-R Model
Symbols used in E-R Model
Entity
▪ An Entity represents a real-world object, concept or thing
about which data is stored in a database. It act as a building
block of a database. Tables in relational database represent
these entities.
Example of entities:
Real-World Objects: Person, Car, Employee etc.
Concepts: Course, Event, Reservation etc.
Things: Product, Document, Device etc.
Types of Entities
i. Strong Entity
▪ A strong Entity is a type of entity that has a key Attribute that
can uniquely identify each instance of the entity.
▪ A Strong Entity does not depend on any other Entity in the
Schema for its identification.
▪ It has a primary key that ensures its uniqueness and is
represented by a rectangle in an E-R diagram.
Types of Entities
ii. Weak Entity
▪ It cannot be uniquely identified by its own attributes alone. It depends on
a strong entity to be identified.
▪ It is associated with an identifying entity (strong entity), which helps in its
identification.
▪ A weak entity are represented by a double rectangle. The participation of
weak entity types is always total.
▪ The relationship between the weak entity type and its identifying strong
entity type is called identifying relationship and it is represented by a
double diamond.
Example
▪ A company may store the information of dependents (Parents,
Children, Spouse) of an Employee. But the dependents can't
exist without the employee.
▪ So dependent will be a Weak Entity Type and Employee will
be identifying entity type for dependent, which means it is
Strong Entity Type.
Example
Attributes in the E-R Model
▪ Attributes are the properties that define the entity type. For
example, for a Student entity Roll_No, Name, DOB, Age,
Address, and Mobile_No are the attributes that define entity
type Student.
▪ In E-R diagram, the attribute is represented by an oval.
Types of Attributes
i. Key Attribute
▪ The attribute which uniquely identifies each entity in the
entity set is called the key attribute.
▪ For example, Roll_No will be unique for each student. In E-R
diagram, the key attribute is represented by an oval with an
underline.
Types of Attributes
ii. Composite Attribute
▪ An attribute composed of many other attributes is called a
composite attribute.
▪ For example, the Address attribute of the student Entity type
consists of Street, City, State, and Country. In ER diagram,
the composite attribute is represented by an oval comprising
of ovals.
Types of Attributes
iii. Multivalued Attribute
▪ An attribute consisting of more than one value for a given
entity. For example, Phone_No (can be more than one for a
given student). In ER diagram, a multivalued attribute is
represented by a double oval.
Types of Attributes
iv. Derived Attribute
▪ An attribute that can be derived from other attributes of the
entity type is known as a derived attribute. e.g.; Age (can be
derived from DOB). In ER diagram, the derived attribute is
represented by a dashed oval.
The Complete Entity Type Student with its Attributes can be
represented as:
Relationship Type
▪ A Relationship type represents the association between
entity types. For example, ‘Enrolled in’ is a relationship type
that exists between entity type Student and Course. In ER
diagram, the relationship type is represented by a diamond
and connecting the entities with lines.
Relationship Set
▪ A set of relationships of the same type is known as a
relationship set. The following relationship set depicts S1 as
enrolled in C2, S2 as enrolled in C1, and S3 as registered in
C3.
Degree of Relationship Set
▪ The number of different entity sets participating in a
relationship set is called the degree of relationship set
Degree of Relationship Set
i. Unary/Recursive Relationship: When there is only ONE
entity set participating in a relation, the relationship is called
a unary relationship. For example, one person is married to
only one person.
Degree of Relationship Set
ii. Binary Relationship: When there are TWO entities set
participating in a relationship, the relationship is called a
binary relationship. For example, a Student is enrolled in a
Course.
Degree of Relationship Set
iii. Ternary Relationship: When there are three entity sets
participating in a relationship, the relationship is called a
ternary relationship.
Degree of Relationship Set
iv. N-ary Relationship: When there are n entities set
participating in a relationship, the relationship is called an n-
ary relationship.
Cardinality in E-R Model
▪ Defines the maximum number of times an entity instance
can participate in a relationship.
▪ Cardinality can be of different types:
i. One-to-One
ii. One-to-Many
iii. Many-to-Many
iv. Many-to-One
Cardinality in E-R Model
i. One-to-One
▪ When each entity in each entity set can take part only once in
the relationship, the cardinality is one-to-one. Let us assume
that one person can be issued only one passport, and one
passport is issued to only one person.
▪ So, the relationship will be One-to-One (1 : 1), meaning that
each person has a single passport, and each passport belongs
to a single person.
Cardinality in E-R Model
i. One-to-One
Cardinality in E-R Model
i. One-to-One
▪ Using Sets, it can be represented as:
Cardinality in E-R Model
ii. One-to-Many
In a one-to-many relationship, one entity can be associated with
multiple entities. For example, a single Surgeon Department can
have many Doctors.
Therefore, the cardinality of this relationship is 1 to M, meaning
one department can have many doctors.
Cardinality in E-R Model
ii. One-to-Many
Cardinality in E-R Model
ii. One-to-Many
▪ Using sets, one-to-many cardinality can be represented as:
Cardinality in E-R Model
iii. Many-to-One
▪ When entities in one entity set can take part only once in the relationship
set and entities in other entity sets can take part more than once in the
relationship set, cardinality is many to one.
▪ Let us assume that multiple surgeries can be performed by one surgeon,
but one surgery is performed by only one surgeon.
▪ So, the cardinality will be M to 1, meaning that many surgeries can be
done by a single surgeon, but each surgery is done by only one surgeon.
Cardinality in E-R Model
iii. Many-to-One
Cardinality in E-R Model
iii. Many-to-One
▪ Using Sets, it can be represented as:
Cardinality in E-R Model
iv. Many-to-Many
▪ When entities in all entity sets can take part more than once in
the relationship cardinality is many to many. Let us assume
that an employee can work on multiple projects and each
project can have multiple employees working on it.
▪ So, the relationship will be many-to-many (M:M), meaning
that one employee may be associated with several projects,
and one project may involve several employees.
Cardinality in E-R Model
iv. Many-to-Many
Cardinality in E-R Model
iv. Many-to-Many
▪ Using Sets, it can be represented as:
In this example, student A1 is enrolled in B1,B2 and B3, and course B3 is taken
by A1, A2, and A3. Therefore, this represents a many-to-many relationship.
How to Draw the E-R Diagram
i. Identify Entities: The very first step is to identify all the Entities.
Represent these entities in a Rectangle and label them accordingly.
ii. Identify Relationships: The next step is to identify the relationship
between them and represent them accordingly using the Diamond shape.
Ensure that relationships are not directly connected to each other.
iii. Add Attributes: Attach attributes to the entities by using ovals. Each
entity can have multiple attributes (such as name, age, etc.), which are
connected to the respective entity.
How to Draw the E-R Diagram
iv. Define Primary Keys: Assign primary keys to each entity.
These are unique identifiers that help distinguish each
instance of the entity. Represent them with underlined
attributes.
v. Remove Redundancies: Review the diagram and eliminate
unnecessary or repetitive entities and relationships.
vi. Review for Clarity: Review the diagram make sure it is clear
and effectively conveys the relationships between the
entities.
Examples of Entities, Attributes & Relationships
i. Courses Entity
Examples of Entities, Attributes & Relationships
ii. Student Entity
Examples of Entities, Attributes & Relationships
iii. Instructor Entity
Examples of Entities, Attributes & Relationships
iv. Course Offering Entity
Complete E-R Diagram