Database Systems - Lecture 5
Database Systems - Lecture 5
Data modeling is the process of creating a visual representation of a system's data elements and
the relationships between them.
It serves as a blueprint for designing and managing databases, ensuring that data is structured
in a way that supports the application's requirements.
Foundation for Database Design: It guides the actual design and implementation of a
database, ensuring that it is efficient, scalable, and aligned with the intended use cases.
Risk Reduction: By identifying potential issues in the design phase, data modeling
reduces the risk of costly errors later in the development process.
1
• Physical Data Model:
• Representational (or Logical) Data Model:
CONCEPTUAL DATA MODEL: The conceptual data model provides a high-level view
of the data. It focuses on the identification of entities, their attributes, and the
relationships between them.
Typically used by business stakeholders and data architects to ensure a common understanding
of the data requirements.
It helps in understanding the overall structure of the data without getting into the technical
details.
PHYSICAL DATA MODEL: The physical data model represents how the data will be
physically stored in the database. It includes details such as table structures, indexes, and
partitions.
• Tables
• Columns
• Data Types
• Indexes, and
• Constraints.
The physical data model is primarily used by database administrators and developers during
the implementation phase.
This model ensures that the database design is optimized for performance, storage, and access.
2
• Foreign Keys and
• Relationships.
It is used by data architects and developers to ensure that the data structures meet the
application requirements.
It bridges the gap between the conceptual model and the physical implementation, ensuring
that the data structures are well-defined and consistent.
KEY TERMS:
1. Key: A key is a field or a combination of fields that uniquely identifies a record within a
table.
TYPES OF KEYS
Primary Key: A primary key is a unique identifier for each record in a table. It cannot
contain NULL values, and each value in the primary key must be unique.
Example:
In a ‘ Customers’ table, a ‘CustomerID’ field could serve as the primary key.
Candidate Key: Any field or set of fields that can uniquely identify a record in a table is
considered a candidate key. A table may have multiple candidate keys, but one of them is
chosen as the primary key.
Composite Key: A composite key is a primary key that consists of two or more fields,
which together uniquely identify a record.
Foreign Key: A foreign key is a field (or a set of fields) in one table that uniquely identifies
a record in another table. It creates a relationship between two tables.
The foreign key is used to enforce referential integrity between the two tables, ensuring that
the relationship between records is maintained.
Example: In an ‘Orders’ table, the ‘CustomerID’ field could be a foreign key that references
the ‘CustomerID’ in the ‘Customers’ table.
2. Record: A record (also known as a row) is a single, complete set of related data items in a
table.
Each record consists of fields (columns), each of which holds a specific piece of data.
3
Example:
In a ‘customers’ table, a record might include fields like ‘CustomerID’, ‘Name’, ‘Address’
and ‘PhoneNumber’
The term "relation" comes from relational algebra, which is the theoretical foundation of
relational databases.
1. Defining Entities and Relationships: Conceptual models identify the key entities (e.g.,
Customer, Order, Product) and their relationships (e.g., A Customer places an Order) within
the domain.
2. Capturing Business Rules: They help in capturing and documenting business rules and
constraints that govern how data should be handled.
3. Providing a Shared Understanding: Conceptual models serve as a communication tool
between business stakeholders and technical teams, ensuring everyone has a common
understanding of the data structure.
4. Supporting System Design: They form the basis for more detailed data models (logical
and physical) and guide the design of databases and software systems.
ENTITY-RELATIONSHIP MODEL (ER MODEL)
This is a representation of data entities, their attributes, and the relationships between them.
The Entity-Relationship (ER) model is one of the most commonly used conceptual modeling
techniques.
4
COMPONENTS OF AN ER MODEL
Entity: An object or concept that can have data stored about it.
• Entities are represented as rectangles in ER diagrams.
Example: Customer Name, Order Date, and Product Price are attributes.
SCENARIO
Consider the doctor consultation relationship found in a medical practice database.
For example, a doctor can have one or many consults on a given day. Therefore, the relationship
between the Doctor entity and the Consult entity is one doctor to many consults (a one-to-many
relationship).
On the other hand, each consult is associated with exactly one diagnosis. So, the relationship
between a Consult and a Diagnosis is a one-to-one relationship.
In other words, cardinality describes a fundamental relationship between two entities or
objects.
There are three relationship types or cardinalities: one-to-one, one-to-many, and many-to-
many. Entity-Relationship (ER) diagrams are used to describe the cardinality in databases.
Class Diagram: The most relevant UML diagram for conceptual modeling. It represents
classes (analogous to entities), their attributes, methods, and relationships.
Inheritance: UML supports inheritance, where a subclass inherits attributes and methods
from a parent class, allowing for the modeling of hierarchical relationships.
STRENGTHS
• Flexibility: Conceptual models are flexible and can be easily modified as requirements
change, without affecting the underlying technical design.
• Foundation for Detailed Design: They serve as a solid foundation for creating more
detailed logical and physical data models.
WEAKNESSES
Lack of Technical Detail: While their abstraction is a strength, it can also be a weakness,
as conceptual models do not provide the technical details needed for implementation.
Limited Direct Use in Implementation: Conceptual models often require translation into
more detailed models before they can be directly used in database design and
implementation.
NOTATIONAL ISSUES
Lack of Standardization: While ER models and UML have widely recognized notations,
different organizations or teams might use variations, leading to confusion.
6
Clarity: The notation used should be clear and intuitive, but overly complex diagrams can
make it difficult for stakeholders to understand the model.
Consistency: Consistent use of symbols and notations is important for ensuring that the
model is easily interpretable by all stakeholders. Inconsistent notations can lead to
misinterpretation and errors.