Professional Documents
Culture Documents
Database Design and Introduction To MySQL Day - 1
Database Design and Introduction To MySQL Day - 1
Database Design and Introduction To MySQL Day - 1
AI-ML
1
Module Name: Database
Design and Introduction to
MySQL
Course : DBMS
Edit Master text styles
Lecture On : Database
Design and Introduction to
MySQL - Day - 4
Instructor :
2
Today’s Agenda
● Revision
● Data Warehouse
● ERD
● Star and Snowflake Schemas
● OLAP vs OLTP
● Entity Constraints
● Referential Constraints
● Key Takeaways
● Imagine you work as a data analyst at DMart and are responsible for three
departments: marketing, sales, and finance. Each department has its own database,
which is an organized collection of data. However, this can lead to different answers
for the same query in different departments, as each department uses its own
database for information. This can become a problem due to the size of DMart's
operations.
● To solve this issue, a data warehouse can provide a unified version of facts and
truth. It acts as a central repository for all the data of the entire organization. This
helps in creating a single source of truth for data analytics. In this section, let's
understand what a data warehouse is and how it can aid data analytics for
companies.
Data Warehouse
● It is designed for a specific purpose and consolidates data from multiple sources
into a single form.
● The diagram displays the following steps in the data warehouse process:
● The data undergoes an Extract, Transform, Load (ETL) process, which consists of:
● The stored data can be utilized for further processing using Online Analytical
Processing (OLAP) or for creating reports using tools such as Tableau or PowerBI.
Data Warehouse
● In data warehousing, the dimension model is utilized to improve data retrieval
speed. This model has two components: Facts and Dimensions.
● Facts refer to numerical information, while dimensions are metadata that provide
context to the facts. Both are crucial in generating meaningful insights from data.
● This diagram acts as a map, enabling us to visualize the database structure and
answer the following questions:
a) Time variant
b) Volatile
c) Disintegrated
d) Subject Oriented
Entity Relationship Diagram (ERD)
● Designing an ERD is a crucial step in data modeling. Before creating the tables, an
ERD is typically created to visualize the relationships between entities in a
database.
Entity Relationship Diagram (ERD)
● Now, let's examine the ERD and understand the symbols used. These symbols
have been described in the accompanying image.
Entity Relationship Diagram (ERD)
● In an ERD, the following notations are used to represent the relationships between
tables:
● You learned about facts and dimensions, which are the two fundamental
components of dimensional modeling.
● When faced with multiple databases containing numerous variables, it may not be
necessary to include all of them in the data model.
● Therefore, only a specific combination of facts and dimensions is used to create the
structure of the data model, known as a schema diagram.
● A schema diagram is a blueprint of the entire data model and demonstrates the
relationships between various data sets and how the attributes of each data set are
utilized in the database design.
○ Simple to comprehend.
○ Efficient when it comes to querying, as they only require one join at most.
● Let's examine the composition of a Star and Snowflake Schema to have a clearer
understanding.
Star and Snowflake Schemas
● Let's take a closer look at the structure of star and snowflake schemas. The diagram
below illustrates the shape of a star schema, which is star-like.
Star and Snowflake Schemas
● The snowflake schema gets its name from its unique structure where the dimension
tables branching off from the central fact table resemble a snowflake.
● When working with a snowflake schema, it's common to split up related dimension
information into separate tables.
● Now, Let’s learn how data warehouses are unique and distinguishable from regular
databases.
● One significant difference between OLTP and OLAP is evident from their names:
OLTP is designed for transactional operations, while OLAP is optimized for
analytical purposes.
● Dimensional modeling and star schema were introduced earlier as crucial elements
in constructing a data warehouse.
● These methods include identifying the variables that can be analyzed and
integrating them with metadata to obtain useful insights.
Entity Constraints
● You learned about the ETL process which is used for transferring data into a
schema and carrying out operations on it.
● But, is it possible to add any value to a schema without restrictions or are there
limitations to maintain the integrity of the schema being established?
● Think about being a data analyst at Uber. The company's data warehouse includes
multiple tables that keep track of different aspects such as the rider's information,
driver's details, the vehicle used and transaction information.
● Suppose you are reviewing the values in a column that records the fare for each
ride. It is reasonable to expect that the fare would not exceed four digits.
● A fare over even ₹5,000 would raise questions and is an anomaly that needs to be
addressed.
● Implementing the appropriate constraints for the appropriate attributes in a table can
prevent such issues.
Entity Constraints
● MySQL uses constraints to establish rules for the values that can be stored in the
columns of a database.
● This helps maintain data integrity, or the accuracy and consistency of the data
stored in the database.
● This type of constraint enforces a relationship between two tables by limiting the
values in one table based on the values in another table.
● One table, called the referencing table, contains a foreign key column that refers to the primary
key column of another table, called the referenced table.
● For example,
○ The 'Orders' table has a foreign key column called 'CustomerID', which refers to the
'Customers' table.
○ By using the foreign key, it is possible to determine which customer placed a particular
order and access all related customer information.
● It's important to note that each table can have only one primary key but multiple foreign keys.
● Before assigning a column as a foreign key, the primary key column in the referenced table
must exist and have no null or duplicate values.
Poll Question
Q. What is the purpose of entity constraints in a database management system?
● Data Warehouse
● ERD
● Star and Snowflake Schemas
● OLAP vs OLTP
● Entity Constraints
● Referential Constraints
Thank You!
29