Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
36 views39 pages

Chapter 1 Introduction To Data Modeling in Snowflake

The document provides an introduction to data modeling in Snowflake, covering key concepts such as data models, entities, attributes, and relationships. It explains the differences between conceptual, logical, and physical data models, along with SQL commands for implementing these models. The document also highlights the importance of primary and foreign keys in establishing relationships between tables.

Uploaded by

paula
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views39 pages

Chapter 1 Introduction To Data Modeling in Snowflake

The document provides an introduction to data modeling in Snowflake, covering key concepts such as data models, entities, attributes, and relationships. It explains the differences between conceptual, logical, and physical data models, along with SQL commands for implementing these models. The document also highlights the importance of primary and foreign keys in establishing relationships between tables.

Uploaded by

paula
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 39

Introduction to Data

Modeling
I N T R O D U C T I O N T O D ATA M O D E L I N G I N S N O W F L A K E

Nuno Rocha
Director of Engineering
Your instructors
Nuno Rocha Margarita Torres

Director of Engineering Senior Data Engineer

INTRODUCTION TO DATA MODELING IN SNOWFLAKE


What is data modeling?

INTRODUCTION TO DATA MODELING IN SNOWFLAKE


What is data modeling? (1)

INTRODUCTION TO DATA MODELING IN SNOWFLAKE


What is data modeling? (2)

INTRODUCTION TO DATA MODELING IN SNOWFLAKE


Components of data modeling

INTRODUCTION TO DATA MODELING IN SNOWFLAKE


Components of data modeling (1)

INTRODUCTION TO DATA MODELING IN SNOWFLAKE


Components of data modeling (2)

INTRODUCTION TO DATA MODELING IN SNOWFLAKE


Components of data modeling (3)

INTRODUCTION TO DATA MODELING IN SNOWFLAKE


Describing entities
Entity: Object or concept represented in a data model

INTRODUCTION TO DATA MODELING IN SNOWFLAKE


Describing entities (1)
DESC TABLE : SQL command to display a table's structure

DESC TABLE groceries;

INTRODUCTION TO DATA MODELING IN SNOWFLAKE


Describing entities (2)
Attribute: Characteristics of an entity

INTRODUCTION TO DATA MODELING IN SNOWFLAKE


Another industry
E-Commerce online retail

INTRODUCTION TO DATA MODELING IN SNOWFLAKE


Terminology and functions overview
Data model: A representation that outlines the organization and storage of data
Entity: Object or concept represented in a data model

Attribute: Characteristics of an entity

Relationship: Connections between entities

DESC TABLE : SQL command to display a table's structure

DESC TABLE table_name;

INTRODUCTION TO DATA MODELING IN SNOWFLAKE


Let's practice!
I N T R O D U C T I O N T O D ATA M O D E L I N G I N S N O W F L A K E
Exploring
Conceptual and
Logical Data Models
I N T R O D U C T I O N T O D ATA M O D E L I N G I N S N O W F L A K E

Nuno Rocha
Director of Engineering
What is a conceptual model?

INTRODUCTION TO DATA MODELING IN SNOWFLAKE


What is a logical data model?

INTRODUCTION TO DATA MODELING IN SNOWFLAKE


Applying the conceptual model
Conceptual model: High-level overview of main data entities

INTRODUCTION TO DATA MODELING IN SNOWFLAKE


Applying the conceptual model (1)
Conceptual model: High-level overview of main data entities

INTRODUCTION TO DATA MODELING IN SNOWFLAKE


Applying the logical model
Logical model: Detailed entities with attributes definition and their relationship

INTRODUCTION TO DATA MODELING IN SNOWFLAKE


Applying the logical model (1)
Relationship cardinality: Number of times entities are associated to each other

INTRODUCTION TO DATA MODELING IN SNOWFLAKE


Implementing the logical model
SELECT FROM : SQL command to fetch columns from a table

SELECT *
FROM ecommerceonlineretail;

INTRODUCTION TO DATA MODELING IN SNOWFLAKE


Implementing the logical model (1)
DESC TABLE ecommerceonlineretail;

INTRODUCTION TO DATA MODELING IN SNOWFLAKE


Implementing the logical model (2)
CREATE TABLE : SQL command to define a new table structure

CREATE OR REPLACE TABLE customers (


customerid NUMBER(38,0),
country VARCHAR(255)
);

INTRODUCTION TO DATA MODELING IN SNOWFLAKE


Terminology and functions overview
Conceptual model: High-level overview of main data entities
Logical model: Detailed entities with attribute definitions and their relationship

Relationship cardinality: Number of times entities are associated with each other

SELECT FROM : SQL command to fetch columns from a table

CREATE OR REPLACE TABLE : SQL command to create or replace a table structure

SELECT * FROM table_name;


CREATE OR REPLACE TABLE table_name (
column_name column_datatype,
another_column column_datatype
);

INTRODUCTION TO DATA MODELING IN SNOWFLAKE


Let's practice!
I N T R O D U C T I O N T O D ATA M O D E L I N G I N S N O W F L A K E
Exploring Physical
Data Models
I N T R O D U C T I O N T O D ATA M O D E L I N G I N S N O W F L A K E

Nuno Rocha
Director of Engineering
The role of the physical model

INTRODUCTION TO DATA MODELING IN SNOWFLAKE


The physical model's details

INTRODUCTION TO DATA MODELING IN SNOWFLAKE


The physical model's details (1)

INTRODUCTION TO DATA MODELING IN SNOWFLAKE


Establishing primary keys
Primary key (PK): Ensures every record in a table has a unique identifier

INTRODUCTION TO DATA MODELING IN SNOWFLAKE


Establishing primary keys (1)
Primary key (PK): Ensures every record in a table has a unique identifier

INTRODUCTION TO DATA MODELING IN SNOWFLAKE


Creating Primary Keys
PRIMARY KEY : SQL clause to define a column as the unique identifier

CREATE OR REPLACE TABLE products (


stockcode VARCHAR(255) PRIMARY KEY,
description VARCHAR(255)
);

INTRODUCTION TO DATA MODELING IN SNOWFLAKE


Establishing foreign keys
Foreign Key (FK): Connects records in different tables to keep the data related

INTRODUCTION TO DATA MODELING IN SNOWFLAKE


Creating foreign keys
FOREIGN KEY () REFERENCES () : SQL clause to define a column that references the primary
key of another table

CREATE OR REPLACE TABLE orders (


invoiceno INT,
customerid INT,
invoicedate DATE,
unitprice DECIMAL(10, 2),
quantity INT,
stockcode VARCHAR(255),
FOREIGN KEY (stockcode) REFERENCES products(stockcode)
);

INTRODUCTION TO DATA MODELING IN SNOWFLAKE


Finalizing the physical data model

INTRODUCTION TO DATA MODELING IN SNOWFLAKE


Terminology and functions overview
Physical data model: Defines how data is stored and accessed, including table structures,
data types, and primary and foreign keys

PRIMARY KEY : SQL clause to define a column as the unique identifier

FOREIGN KEY (...) REFERENCES (...) : SQL clause to create a link between two tables

CREATE OR REPLACE TABLE table_name (


unique_column column_datatype PRIMARY KEY,
other_columns column_datatype,
foreign_column column_datatype,
FOREIGN KEY (foreign_column) REFERENCES foreign_table(PK_from_foreign_table)
);

INTRODUCTION TO DATA MODELING IN SNOWFLAKE


Let's practice!
I N T R O D U C T I O N T O D ATA M O D E L I N G I N S N O W F L A K E

You might also like