0% found this document useful (0 votes)
14 views24 pages

Data Models

Uploaded by

clandestinemolo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views24 pages

Data Models

Uploaded by

clandestinemolo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

DATA MODELS

In a Database Management System


(DBMS), data models define how data is
stored, organized, and manipulated. They
provide a structured framework for
representing data relationships, constraints,
and operations.
9 Major types of Data Models in DBMS
1. Hierarchical Data Model
•Structure: Data is organized in a tree-like structure, where
records have parent-child relationships. A parent can have
multiple children, but each child has only one parent.
•Use Case: This model is used in applications that require a
clear hierarchy, such as file systems and organizational charts.
•Example:
• A university database where a "Department" is the parent,
and "Courses" are its children.
Key Features of the Hierarchical Data Model:
1. Tree Structure: Data is represented in a hierarchy, where each level
represents a certain category of information. The top node is called the
root, and the bottom nodes are called leaves.
2. Parent-Child Relationship: Each child node has one parent, while a parent
node can have multiple child nodes.
3. One-to-Many Relationships: The model is designed for one-to-many
relationships, where one parent node can have many child nodes, but
each child has only one parent.
4.Fast Data Access: Navigating hierarchical data is fast, especially when data
naturally fits this model.
5.Inflexibility: It is difficult to model complex relationships that do not follow
a strict hierarchy, such as many-to-many relationships.
Example:
In a library management system, the hierarchical model could look like this:
Root (Library)
├── Section (Science)
│ ├── Subsection (Physics)
│ │ ├── Book (Quantum Mechanics)
│ │ └── Book (Relativity)
│ └── Subsection (Chemistry)
│ ├── Book (Organic Chemistry)
│ └── Book (Inorganic Chemistry)
└── Section (Literature)
├── Subsection (Poetry)
└── Subsection (Novels)
├── Book (Moby Dick)
└── Book (Pride and Prejudice)
The Library is the root node, and Sections (Science, Literature) and Subsections (Physics, Chemistry) form different
hierarchical levels under the root. Each Book represents a leaf node.
Operations in a Hierarchical Data Model:
•Traversal: Accessing data involves starting from the root and traversing down to the
desired child.
•Insertion: Data can be easily inserted as new child nodes to an existing parent.
•Deletion: Removing a node could require restructuring, particularly when it has child
nodes.
•Updates: Changes to a parent node can propagate to its children due to the parent-child
dependency.
Hierarchical Model Examples:
1.File System:
1.A typical example is the organization of files in directories and
subdirectories in an operating system.
2.Organizational Chart:
1.A company’s hierarchy can be represented, where the CEO is at the
top, with managers and employees in subsequent levels.
3.XML:
1.XML data format follows a hierarchical structure with nested
elements, similar to how a hierarchical database stores records.
2. Network Data Model
•Structure: Data is organized as a graph with many-to-
many relationships. Each record (node) can have multiple
parents and children.
•Use Case: This model is suitable when entities have
complex relationships, such as supply chain management.
•Example:
• A transportation network where multiple routes
(nodes) connect cities (other nodes) in a flexible, non-
hierarchical way.
Key Characteristics of the Network Data Model:
1. Graph-Like Structure: Data is organized as a network of nodes
(records) and edges (relationships), enabling more flexible
relationships compared to hierarchical models.
2. Many-to-Many Relationships: Unlike the hierarchical model,
which only supports one-to-many relationships, the network
model supports many-to-many relationships between records.
3. Flexible Navigation: The network model allows traversing
records in multiple directions, making it more flexible for
complex queries and data retrieval.
4.Pointers: Relationships between entities are established using
pointers, which allow for efficient linking between data records.
Example:
Consider a university system where students can enroll in multiple courses,
and each course can have many students.

In this case:
•Students (A, B, C) are nodes.
•Courses (Course 1, Course 2, Course 3) are also nodes.
•The relationships (enrollments) between students and courses are edges, representing the many-to-
many nature of the relationship.
Components of the Network Data Model:
1. Records: The data itself, representing entities (such as students, courses,
etc.).
2. Sets: Relationships between records. A set consists of an owner record (e.g.,
a course) and member records (e.g., students).
3. Pointers: The links that connect records within sets, allowing for navigation
from one record to another.
Operations in the Network Data Model:
• Traversal: Since records are linked via pointers, you can navigate
between related records (e.g., from a student to all the courses
they are enrolled in).
• Insertion and Deletion: Inserting or deleting records requires
managing the pointers and updating the sets accordingly.
• Updates: Changes to records can affect all related sets, requiring
updates to the pointers.
Advantages:
1.Efficient Many-to-Many Relationships: The network
model can handle complex many-to-many relationships
that are difficult to manage in a hierarchical model.
2.Data Integrity: Since relationships are explicitly defined,
the integrity of data is easier to maintain in network
structures.
3.Flexible Querying: Supports complex queries and
retrieval, especially when multiple relationships need to
be traversed.
Disadvantages:
1. Complexity: The model is more complex than
hierarchical or relational models, and managing pointers
can be difficult.
2. Difficult to Implement: Maintaining sets and pointers
requires careful programming and system design,
making it harder to implement in practice.
3.Reduced Popularity: The network model has largely
been replaced by the relational model in most database
systems due to its simplicity and flexibility.
Comparison with Other Data Models:
Use Cases:
• Telecommunication networks: Representing how various
network nodes (routers, switches) are interconnected.
• Transportation systems: Modeling routes between cities
or stations.
• Complex inventory systems: Where many products can
belong to many categories or suppliers.
3. Relational Data Model
•Structure: Data is represented in tables (relations), where
each table consists of rows (records) and columns
(attributes). Tables can be linked through keys.
•Use Case: It is the most widely used model in databases
today, supporting SQL queries for manipulating data.
•Example:
• A student database with tables for "Students,"
"Courses," and "Enrollments," where relationships
between these entities are managed through primary
and foreign keys.
Tables:
1.Students
•Stores information about each student.
•Primary Key: StudentID
2. Courses
•Stores information about courses.
•Primary Key: CourseID
3. Enrollments
•Stores information about which students are enrolled in which
courses.
•Primary Key: Composite key of StudentID and CourseID (both
are foreign keys).
•Foreign Keys: StudentID (from Students table) and CourseID
(from Courses table).
Relational Model Concepts:
1.Primary Key: Uniquely identifies each record in a table. For example,
StudentID is the primary key in the Students table, and CourseID is the
primary key in the Courses table.
2. Foreign Key: A field in one table that refers to the primary key in
another table. For example, in the Enrollments table, StudentID refers
to the primary key of the Students table, and CourseID refers to the
primary key of the Courses table.
3.Many-to-Many Relationship: The relationship between Students and
Courses is many-to-many because:
•A student can enroll in multiple courses.
•A course can have multiple students enrolled.
4. Entity-Relationship (ER) Model
•Structure: Focuses on representing entities (objects) and
relationships between them. An ER diagram is used to
visualize entities, attributes, and their relationships.
•Use Case: Primarily used during database design to model
real-world scenarios.
•Example:
• A hospital database might have entities like "Patients,"
"Doctors," and "Appointments," with relationships
between them.
ERD Diagram

You might also like