Data Models
Data Models
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