Introduction To Relational Databases Using Postgres
Data Modelling in Relational Database
S Soumen
Oct 3, 2023
 Introduction to Data Modelling in Relational Databases

Introduction to Data Modelling

What is Data Modelling? - Data modelling is the process of creating a data model for the data to be stored in a database. This process involves determining the data elements and the relationships between them.

Importance of Relational Data Modelling - Provides a clear structure for the database that is intuitive and scalable. - Ensures data integrity and reduces redundancy through normalization. - Facilitates easier data retrieval and manipulation with SQL.


Various Data Modelling Techniques

Hierarchical Models - Structure: Tree-like structure with parent-child relationships. - Each parent can have multiple children, but each child has only one parent. - Example: Organization charts, file systems.

Network Models - Structure: More flexible than hierarchical, allowing many-to-many relationships. - Data is organized in a graph, with records as nodes and relationships as edges. - Example: Transport networks, social networks.

Relational Models - Structure: Organizes data in tables (relations), which consist of rows and columns. - Each table represents an entity, and relationships are established through keys. - Example: Student database with tables for Students, Courses, and Enrollments.


Relational Model in Detail

Tables - The foundation of the relational model. Each table represents an entity. - Composed of rows and columns, rows represent records and columns represent attributes.

Rows - Each row in a table represents a unique instance of the entity defined by the table.

Columns - Each column represents an entity's attribute, defining a specific piece of data that the table stores for each record.

Primary Keys - A column or a set of columns used to uniquely identify each row in a table. - Example: A 'StudentID' column in a 'Students' table, where each student has a unique ID.

Foreign Keys - A column or a set of columns in one table that refers to the primary key in another table. - Establishes a relationship between two tables. - Example: An 'Enrollment' table may have a 'StudentID' column that refers to the 'StudentID' in the 'Students' table, linking each enrollment record to a specific student.


#### Example of  Relational Models  Students Table - Columns: StudentID (Primary Key), Name, Age, Major - Rows: Each row represents a different student with a unique StudentID.

 Courses Table - Columns: CourseID (Primary Key), CourseName, Department - Rows: Each row represents a different course with a unique CourseID.

 Enrollments Table - Columns: EnrollmentID (Primary Key), StudentID (Foreign Key), CourseID (Foreign Key), Semester - Rows: Each row represents a student's enrollment in a course for a specific semester. - The StudentID links to the Students table, and the CourseID links to the Courses table.


Have a doubt?
Post it here, our mentors will help you out.