DBMS Data Models – Hierarchical, Network, Relational & Object-Oriented
Data models define how data is stored, organized, and manipulated in a database. They provide a conceptual framework to represent real-world entities and relationships.
1. Hierarchical Data Model
Data is organized in a tree structure with parent-child relationships. Each child has only one parent.
-- Oracle Example: Department → Employee CREATE TABLE department ( dept_id NUMBER PRIMARY KEY, dept_name VARCHAR2(50) ); CREATE TABLE employee ( emp_id NUMBER PRIMARY KEY, emp_name VARCHAR2(50), dept_id NUMBER REFERENCES department(dept_id) ); SELECT d.dept_name, e.emp_name FROM department d JOIN employee e ON d.dept_id = e.dept_id ORDER BY d.dept_id;
2. Network Data Model
Data is represented as records (nodes) and links (edges), supporting many-to-many relationships.
-- Oracle Example: Employee ↔ Project CREATE TABLE project ( project_id NUMBER PRIMARY KEY, project_name VARCHAR2(50) ); CREATE TABLE employee ( emp_id NUMBER PRIMARY KEY, emp_name VARCHAR2(50) ); CREATE TABLE project_assignment ( project_id NUMBER REFERENCES project(project_id), emp_id NUMBER REFERENCES employee(emp_id), PRIMARY KEY(project_id, emp_id) );
3. Relational Data Model
Data is stored in tables (relations) with rows (tuples) and columns (attributes). Relationships are defined with primary and foreign keys.
-- Oracle Example: Student / Course / Enrollment CREATE TABLE student ( student_id NUMBER PRIMARY KEY, name VARCHAR2(50), course VARCHAR2(50) ); CREATE TABLE course ( course_id NUMBER PRIMARY KEY, title VARCHAR2(50) ); CREATE TABLE enrollment ( student_id NUMBER REFERENCES student(student_id), course_id NUMBER REFERENCES course(course_id), PRIMARY KEY(student_id, course_id) );
4. Object-Oriented Data Model
Integrates object-oriented programming concepts into database storage. Stores objects, attributes, and methods.
-- Oracle Object Type Example CREATE TYPE Student_Type AS OBJECT ( student_id NUMBER, name VARCHAR2(50), course VARCHAR2(50), MEMBER FUNCTION getDetails RETURN VARCHAR2 ); / CREATE TABLE Student_Obj OF Student_Type; INSERT INTO Student_Obj VALUES (Student_Type(101, 'Ahsan', 'DBMS'));
Comparison Table
| Feature | Hierarchical | Network | Relational | Object-Oriented |
|---|---|---|---|---|
| Structure | Tree | Graph | Table | Objects / Classes |
| Relationships | 1-to-many | Many-to-many | Any via keys | Any via objects |
| Flexibility | Low | Medium | High | High |
| Oracle Example | Dept → Employee | Employee ↔ Project | Student / Course / Enrollment | Object Types / Student_Obj table |
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন