In this lesson, you will explore the Northwind database schema and understand its structure before designing a graph model.
Northwind Schema Overview
This lesson explores the Northwind schema introduced in Module 1. The following tables are the focus for graph modelling.
Core Business Tables
| Table |
Description |
customers
|
Companies that purchase products. Contains contact information, addresses, and company details. |
orders
|
Purchase orders placed by customers. Links to customers, employees, and shippers. |
order_details
|
Line items within orders. Links orders to products with quantity, price, and discount. |
products
|
Items available for sale. Links to categories and suppliers. |
categories
|
Product groupings (e.g., Beverages, Dairy Products, Seafood). |
suppliers
|
Companies that provide products. Contains contact and address information. |
employees
|
Staff members who process orders. Includes a self-referencing reports_to column for the management hierarchy. |
shippers
|
Delivery companies that transport orders. |
Supporting Tables
| Table |
Description |
territories
|
Geographic sales regions assigned to employees. |
region
|
Broader geographic areas containing territories. |
employee_territories
|
Junction table linking employees to their assigned territories. |
customer_demographics
|
Customer classification types. |
customer_customer_demo
|
Junction table linking customers to demographic types. |
us_states
|
Reference table for US state information. |
Analyzing Schema Structure
To design your graph model, you need to understand the source schema: tables, columns, and foreign keys. The queries below use standard SQL (information_schema). Similar catalogs exist in BigQuery, Snowflake, and other relational databases.
View Table Columns
To see the columns in a specific table:
Count Records in Tables
Understanding the data volume helps with import planning:
Understanding Foreign Keys
Foreign keys define the relationships between tables. These will become relationships in your graph model.
Run this query to see all foreign key relationships:
Relationships in Northwind
The query above reveals these important relationships:
| Source Table |
Foreign Key |
References |
orders
|
customer_id
|
customers.customer_id
|
orders
|
employee_id
|
employees.employee_id
|
orders
|
ship_via
|
shippers.shipper_id
|
order_details
|
order_id
|
orders.order_id
|
order_details
|
product_id
|
products.product_id
|
products
|
category_id
|
categories.category_id
|
products
|
supplier_id
|
suppliers.supplier_id
|
employees
|
reports_to
|
employees.employee_id
|
Sample Data Exploration
Before modelling, explore some actual data to understand its structure:
Check Your Understanding
Analyzing a Relational Schema
Which SQL query would you use to find all foreign key relationships in a relational database?
-
❏ SELECT * FROM pg_tables
-
❏ SHOW FOREIGN KEYS
-
✓ Query the information_schema.table_constraints table with constraint_type = 'FOREIGN KEY'
-
❏ DESCRIBE TABLE relationships
Hint
Relational databases typically store constraint information in system catalogs such as information_schema.
Solution
Query the information_schema.table_constraints table and filter by constraint_type = 'FOREIGN KEY'. This returns all foreign key constraints. Similar catalogs exist in BigQuery, Snowflake, and other relational databases.
Summary
In this lesson, you explored the Northwind database schema and learned:
-
The main tables and their purposes
-
How to analyze relational schema structure (tables, columns, foreign keys)
-
The foreign key relationships between tables
-
How to explore sample data
In the next lesson, you will identify which tables should become nodes in your graph model.