Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Data Modeling

Data Modeling refers to the process of creating relationships between multiple tables based on a
common field (column). Its primary purpose is to structure data in a way that supports efficient
querying and analysis.

In data modeling, two main types of tables are commonly used:

1. Dimension Table
2. Fact Table

i. Dimension Table (Dim Table):

• Dimension tables are also known as parent tables, primary key tables, or master tables.
• They are referred to as parent tables because their columns are used as references by child
tables to maintain data integrity.
• These tables are considered master tables because they contain unique records, with each
record occurring only once.
• Example: In a sales database, a "Products" dimension table contains unique product
information, and a "Customers" dimension table contains unique customer details.

ii. Fact Table:


• Fact tables are also known as child tables, foreign key tables, or transactional tables.
• They are called child tables because their columns often reference columns in dimension
tables to obtain values.
• Fact tables are considered transactional tables because they store repeated or redundant
records, typically representing real-time data.
• Example: In the same sales database, an "Orders" fact table contains detailed order data,
including references to the "Products" and "Customers" dimension tables.

To create an effective data model, dimension tables and fact tables need to be connected in specific
ways, commonly achieved through two schema designs:

1. Star Schema
2. Snowflake Schema

i. Star Schema:
• The star schema design is named for its resemblance to a star.
• It is the most popular and preferred design due to its simplicity and ease of use.
• In a star schema, the fact table is directly connected to dimension tables.
• Example: In a retail database, the "Sales" fact table is connected to dimension tables like
“Date”, "Products", "Employee", “SalesTerritory”, and “Reseller”.

ii. Snowflake Schema:


• The snowflake schema design resembles a snowflake due to its branching structure.
• It is used in specific scenarios where more complex data relationships are necessary.
• In a snowflake schema, the fact table is connected to dimension tables, but the dimension
tables can be further divided into sub-dimension tables. To connect the fact table with sub-
dimensions, a bridge table in the form of a dimension table is used.
• Example: In an e-commerce database, the "Orders" fact table is connected to sub-dimensions
like "Product Category" through a bridge table.
Types of Relationships in Data Modeling:

i. 1-to-Many Relationship:
• This relationship is established between a dimension table and a fact table.
• It's named 1-to-Many because each record in the dimension table has a single occurrence,
while the fact table contains multiple occurrences of related data.
• Example: In a university database, the "Students" dimension table has a 1-to-Many
relationship with the "Courses" fact table because each student can enrol in multiple courses.

ii. 1-to-1 Relationship:

• This relationship exists between two-dimension tables.


• It's called 1-to-1 because both dimension tables have only one occurrence for each record.
• Example: In a hospital database, the "Doctors" dimension table may have a 1-to-1 relationship
with the "Specialties" dimension table, as each doctor specializes in only one area.

iii. Many-to-Many Relationship:


• This relationship is established between two fact tables.
• It's named Many-to-Many because both fact tables contain multiple occurrences of related
records.
• Example: In a library database, the "Books Borrowed" fact table may have a Many-to-Many
relationship with the "Library Members" fact table, as each member can borrow multiple
books, and each book can be borrowed by multiple members.

You might also like