Relational model in DBMS
In relational model, the data and relationships are represented by collection of
inter-related tables. Each table is a group of column and rows, where column
represents attribute of an entity and rows represents records.
Sample relationship Model: Student table with 3 columns and four records.
Table: Student
Stu_Id Stu_Name Stu_Age
111 Ashish 23
123 Saurav 22
169 Lester 24
234 Lou 26
Table: Course
Stu_Id Course_Id Course_Name
111 C01 Science
111 C02 DBMS
169 C22 Java
169 C39 Computer Networks
Here Stu_Id, Stu_Name & Stu_Age are attributes of table Student and Stu_Id,
Course_Id & Course_Name are attributes of table Course. The rows with values
are the records (commonly known as tuples).
Hierarchical model in DBMS
In hierarchical model, data is organized into a tree like structure with each
record is having one parent record and many children. The main drawback of this
model is that, it can have only one to many relationships between nodes.
Note: Hierarchical models are rarely used now.
Sample Hierarchical Model Diagram:
Lets say we have few students and few courses and a course can be assigned to
a single student only, however a student take any number of courses so this
relationship becomes one to many.
Example of hierarchical data represented as relational tables: The above
hierarchical model can be represented as relational tables like this:
Stu_Id Stu_Name Stu_Age
123 Steve 29
367 Chaitanya 27
234 Ajeet 28
Course Table:
Course_Id Course_Name Stu_Id
C01 Cobol 123
C21 Java 367
C22 Perl 367
C33 JQuery 234