SnowflakeTutorial

Tutorial 1: Building Your First Data Warehouse

*Time**: 45 minutes

11 min read

Tutorial 1: Building Your First Data Warehouse

Time: 45 minutes Difficulty: Beginner Cost: $0 (uses free trial credits)


What You'll Build

A complete cloud data warehouse that:

  • Stores customer and sales data
  • Loads data from CSV files
  • Processes analytical queries
  • Creates business intelligence views
  • Demonstrates Time Travel and cloning

By the end, you'll have a working data warehouse with sample retail data.


What You'll Learn

  • How to create and organize databases
  • Loading data from files
  • Writing analytical SQL queries
  • Creating views for reporting
  • Using Time Travel for data recovery
  • Zero-copy cloning for dev/test

Prerequisites

  • Snowflake trial account (if not set up, see Getting Started Guide)
  • Basic SQL knowledge (SELECT, JOIN, GROUP BY)
  • Web browser

Architecture Overview

What we're building:

  • Database: retail_dwh
  • Schemas: raw, analytics
  • Tables: customers, orders, products, order_items
  • Views: customer_summary, product_performance

Step 1: Set Up Your Environment

Create Database Structure

Create Virtual Warehouse


Step 2: Create Tables

Customers Table

Products Table

Orders Table

Order Items Table


Step 3: Load Sample Data

Create Sample Data Files

customers.csv:

products.csv:

orders.csv:

order_items.csv:

Load Data via Web UI

  1. Create Internal Stage:

  2. Upload Files via Web UI:

    • Go to Data > Databases > retail_dwh > raw > Stages
    • Click on tutorial_stage
    • Click + Files button
    • Upload all 4 CSV files
  3. Verify Files:

Create File Format

Load Data into Tables


Step 4: Write Analytical Queries

Basic Exploration

Join Orders with Customers

Calculate Order Totals

Product Performance


Step 5: Create Analytics Views

Customer Summary View

Product Performance View


Step 6: Time Travel Demo

Make Changes to Data

Recover with Time Travel

Query at Specific Timestamp


Step 7: Zero-Copy Cloning

Clone for Development

Clone for Testing


Step 8: Monitor Your Usage

Query History

Warehouse Usage

Storage Usage


Checkpoint: What You've Built

Data Warehouse Structure:

  • 1 database with 2 schemas
  • 4 raw tables with sample data
  • 2 analytics views

Skills Demonstrated:

  • Creating databases and schemas
  • Loading data from CSV
  • Writing analytical SQL
  • Creating views
  • Time Travel for recovery
  • Zero-copy cloning

Queries You Can Run:


Challenge Exercises

Challenge 1: Add Order Metrics

Create a view order_summary that shows:

  • Order ID
  • Customer name
  • Order date
  • Number of items
  • Subtotal
  • Total discounts
  • Final total
Show Solution

Challenge 2: Monthly Revenue Trend

Write a query showing total revenue by month.

Show Solution

Challenge 3: Customer Segmentation

Classify customers into tiers based on lifetime value:

  • VIP: > $1000
  • High-Value: $500-$1000
  • Medium-Value: $100-$500
  • Low-Value: < $100
Show Solution

Cleanup (Optional)

To remove all resources and stop incurring costs:


What's Next?

Congratulations! You've built your first Snowflake data warehouse. Continue learning:

  1. Tutorial 2: Data Loading & Transformation - External stages and Snowpipe
  2. Best Practices - Optimization techniques
  3. Use Cases - Real-world implementations

Need Help?


Ready for more? Continue to Tutorial 2: Data Loading & Transformation

Stay in the loop

Get weekly insights on data engineering, analytics, and AI—delivered straight to your inbox.

No spam. Unsubscribe anytime.