Data models define how data is organized, stored, and accessed in a database management system (DBMS). Below are explanations of four common data models with small examples.
The relational model organizes data into tables (relations) consisting of rows (tuples) and columns (attributes). It uses keys to establish relationships between tables.
Example: A simple "Employees" table.
| ID | Name | Department | |----|---------|------------| | 1 | Alice | HR | | 2 | Bob | IT | | 3 | Charlie | Sales |
The hierarchical model organizes data in a tree-like structure with parent-child relationships, where each child has only one parent.
Example: Company organization chart.
CEO ├── Manager HR │ └── Employee Alice └── Manager IT └── Employee Bob
The network model allows more complex relationships where a child can have multiple parents, represented as a graph with records and sets.
Example: Students and Courses (a student can enroll in multiple courses, a course can have multiple students).
Student A ── Enrolls ── Course 1 Student A ── Enrolls ── Course 2 Student B ── Enrolls ── Course 1
The document model stores data in flexible, semi-structured documents (e.g., JSON or XML), allowing nested structures without a fixed schema.
Example: A user profile document.
{ "id": 1, "name": "Alice", "address": { "street": "123 Main St", "city": "Anytown" }, "hobbies": ["reading", "traveling"] }
DBMS architectures define how the database system is structured in terms of processing and data distribution. Below is a visual comparison using diagrams with flow animations.
All processing and data storage occur on a single central machine. Users access it directly.
Clients handle user interfaces and some processing, while the server manages the database and heavy operations. Communication occurs over a network.