The network model is a data model that organizes data in a graph structure, where records are represented as nodes and relationships between them as edges. This model allows for more complex relationships than hierarchical models, enabling many-to-many connections. It is particularly useful in applications where relationships among data are intricate and require flexibility in navigation.
Graph Structure: The network model uses a graph structure with nodes (records) and edges (relationships), allowing for multiple relationships between records.
Pointers: Each record can contain pointers to other records, allowing direct navigation through the network.
Many-to-Many Relationships: Unlike the hierarchical model, where relationships are strictly one-to-many, the network model supports many-to-many relationships.
Schema Definition: The schema in a network database is defined in terms of sets, which describe how records are related.
Navigational Access: Similar to the hierarchical model, data access is navigational, requiring knowledge of the paths to traverse.
Records: The basic unit of data, equivalent to a row in a relational database. Each record can contain multiple fields.
Sets: A collection of records that are related. Each set has a parent record and one or more child records.
Pointers: Links between records that indicate relationships.
Let’s illustrate the network model using a university database that includes students, courses, and instructors. The relationships can be defined as follows:
Below is a visual representation of the university database:
The schema for the university database can be defined as follows:
Student Record
Course Record
Instructor Record
Enrollment Set: Represents the relationship between Students and Courses.
Teaching Set: Represents the relationship between Courses and Instructors.
To implement the network model, we can use specific database management systems designed for network data, such as Integrated Data Store (IDS) or CODASYL DBTG.
However, for illustration, we will describe a conceptual implementation that uses pseudo-SQL to demonstrate how data would be structured and manipulated.
-- Create Student Records
INSERT INTO Students (StudentID, Name) VALUES (1, 'Alice');
INSERT INTO Students (StudentID, Name) VALUES (2, 'Bob');
INSERT INTO Students (StudentID, Name) VALUES (3, 'Charlie');
-- Create Course Records
INSERT INTO Courses (CourseID, Title) VALUES (101, 'Database Systems');
INSERT INTO Courses (CourseID, Title) VALUES (102, 'Operating Systems');
INSERT INTO Courses (CourseID, Title) VALUES (103, 'Computer Networks');
-- Create Instructor Records
INSERT INTO Instructors (InstructorID, Name) VALUES (201, 'Dr. Smith');
INSERT INTO Instructors (InstructorID, Name) VALUES (202, 'Dr. Jones');
To define the relationships between students, courses, and instructors, we would use sets.
-- Enrollment Set (Student to Course)
-- Alice enrolls in Database Systems and Operating Systems
CREATE SET Enrollment;
ADD TO Enrollment (1, 101);
ADD TO Enrollment (1, 102);
-- Bob enrolls in Computer Networks
ADD TO Enrollment (2, 103);
-- Charlie enrolls in all courses
ADD TO Enrollment (3, 101);
ADD TO Enrollment (3, 102);
ADD TO Enrollment (3, 103);
-- Teaching Set (Course to Instructor)
-- Database Systems is taught by Dr. Smith
CREATE SET Teaching;
ADD TO Teaching (101, 201);
-- Operating Systems is taught by Dr. Jones
ADD TO Teaching (102, 202);
-- Computer Networks is taught by Dr. Smith
ADD TO Teaching (103, 201);
Querying in a network model often involves traversing through the sets and records. Although a standard SQL-like language is not universally applicable, the following pseudo-queries represent how one might retrieve data.
SELECT c.Title
FROM Enrollment e
JOIN Courses c ON e.CourseID = c.CourseID
WHERE e.StudentID = 1; -- Alice's StudentID
Example 2: Find Instructors for a Specific Course
SELECT i.Name
FROM Teaching t
JOIN Instructors i ON t.InstructorID = i.InstructorID
WHERE t.CourseID = 101; -- Database Systems
Example 3: Find All Students in a Course
SELECT s.Name
FROM Enrollment e
JOIN Students s ON e.StudentID = s.StudentID
WHERE e.CourseID = 102; -- Operating Systems
To update a student’s enrollment or change an instructor for a course, we would adjust the records accordingly.
-- Remove Alice from Operating Systems
DELETE FROM Enrollment WHERE StudentID = 1 AND CourseID = 102;
-- Enroll Alice in Computer Networks
ADD TO Enrollment (1, 103);
When a record is deleted, it is essential to consider the relationships to maintain integrity.
-- Remove a course and associated enrollments
DELETE FROM Courses WHERE CourseID = 102; -- Operating Systems
DELETE FROM Enrollment WHERE CourseID = 102; -- Remove related enrollments
The network model is particularly well-suited for certain applications, such as:
Telecommunications: Network databases can effectively manage complex routing tables and connections.
Transportation Systems: Managing routes and connections between different locations, where multiple paths may exist between points.
Manufacturing: Managing supply chains, where multiple suppliers may provide the same part and each part may be used in multiple products.
Human Resource Management: Representing employee relationships, departments, and roles within an organization.
Complex Relationships: The model can efficiently represent complex relationships between entities.
Data Integrity: Relationships are explicitly defined, which helps maintain data integrity.
Performance: Direct pointers enable fast access to related records, enhancing performance in many cases.
Complexity: The structure can become complicated, making it challenging for users to understand and manipulate.
Rigidity: Changes to the database schema can require significant effort, especially if the relationships are deeply nested.
Limited Standardization: Unlike the relational model, which is standardized (SQL), the network model lacks a widely accepted query language.