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

Database Systems - Lecture 5

Uploaded by

Meregulwa Allan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Database Systems - Lecture 5

Uploaded by

Meregulwa Allan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

DATA MODELING

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.

THE ROLE OF DATA MODELING

 Understanding Requirements: Data modeling helps in translating business requirements


into a technical framework, making it easier to understand what data is needed and how it
should be organized.

 Communication Tool: It provides a common language for stakeholders (business


analysts, developers, and database administrators) to discuss and agree on the structure
and semantics of the data.

 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.

BENEFITS OF DATA MODELING


• Improved Data Quality: By defining data structures and relationships clearly, data
modeling ensures data consistency and integrity, leading to higher data quality.
• Enhanced Performance: Well-structured data models enable efficient data retrieval and
storage, which can improve the performance of applications and databases.
• Easier Maintenance and Scalability: A well-designed data model makes it easier to update
and scale the system as requirements change, reducing maintenance costs.
• Better Decision-Making: Accurate and well-organized data models support better analytics
and reporting, leading to informed decision-making.
• Compliance and Security: Data modeling helps in ensuring that the database design meets
regulatory requirements and includes necessary security measures to protect sensitive data.

COMMON APPROACHES TO DATA MODELING


Data modeling can be approached in different ways depending on the level of abstraction and
the specific needs of the project.

Three main types of data models


• Conceptual Data Model:

1
• Physical Data Model:
• Representational (or Logical) Data Model:

TYPES OF DATA MODELS

 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.

FEATURES OF CONCEPTUAL DATA MODELS

• Entities (e.g., Customer, Product)


• Relationships (e.g., Customer purchases Product) and
• Attributes (e.g., Customer Name, Product Price).

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.

FEATURES OF PHYSICAL DATA MODELS

• 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.

 REPRESENTATIONAL (OR LOGICAL) DATA MODEL: This data model provides a


more detailed view of the data compared to the conceptual model. It defines the structure
of the data elements and the relationships between them without considering the physical
implementation.

FEATURES OF REPRESENTATIONAL (OR LOGICAL) DATA MODEL:


• Entities
• Attributes
• Primary Keys

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.

BASIC CONCEPTS IN DATA MODELING


Understanding the basic concepts in data modeling is essential for designing and managing
databases.

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.

Example: In an ‘Orders’ table, a combination of ‘OrderID’ and ‘ProductID’ might serve


as a composite key

 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’

3. Relation: A relation, in the context of a relational database, is a table. It consists of rows


(records) and columns (fields).

The term "relation" comes from relational algebra, which is the theoretical foundation of
relational databases.

KEY CHARACTERISTICS OF A RELATION

 Each relation (table) must have a unique name.


 Every relation is composed of tuples (rows), where each tuple is a unique combination of
attribute values.
 The attributes (columns) in a relation must have unique names within that table.
 Relations can have various types of relationships between them, such as one-to-one, one-
to-many, and many-to-many, typically managed using keys and foreign keys.

CONCEPTUAL MODELS IN DATA MODELING


Conceptual models are abstract representations of the data elements and their relationships
within a system.
They are typically the first step in the data modeling process and focus on understanding the
high-level structure of the data without diving into technical details.

THE MAIN POSSIBILITIES IN CONCEPTUAL MODELING

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: In a retail system, Customer, Order, and Product might be entities.

 Attribute: A property or characteristic of an entity.


• Attributes are typically shown as ovals connected to their respective entities.

Example: Customer Name, Order Date, and Product Price are attributes.

 Relationship: A connection between two or more entities.


• Relationships are represented by diamonds in ER diagrams.
Example: A Customer places an Order.
 Cardinality: Cardinality refers to the relationships between the data in two database tables.
• Cardinality defines how many instances of one entity are related to instances of another
entity.

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.

UNIFIED MODELING LANGUAGE (UML)


The Unified Modeling Language (UML) is a standardized modeling language used in software
engineering.
It offers various diagrams to represent different aspects of systems, including conceptual data
models.
5
COMPONENTS OF UML

 Class Diagram: The most relevant UML diagram for conceptual modeling. It represents
classes (analogous to entities), their attributes, methods, and relationships.

 Associations: Connections between classes in a UML class diagram, similar to relationships


in an ER model.

 Multiplicity: UML's equivalent to cardinality, indicating the number of instances of one


class that can be associated with instances of another class.

 Inheritance: UML supports inheritance, where a subclass inherits attributes and methods
from a parent class, allowing for the modeling of hierarchical relationships.

STRENGTHS AND WEAKNESSES OF CONCEPTUAL MODELS

STRENGTHS

• Abstraction: Conceptual models provide a high level of abstraction, making it easier to


understand the overall structure of the system without getting lost in technical details.

• Communication: They facilitate communication between stakeholders, ensuring that the


business requirements are accurately captured and understood.

• 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.

 Potential Ambiguity: Without standardized notations, conceptual models can sometimes


be ambiguous, leading to misinterpretations.

 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.

You might also like