Import

Introduction

You are going to import a relational dataset into your Neo4j Aura instance using the Import tool.

You will:

  1. Create a new graph data model from the Northwind dataset

  2. Build the graph data model in stages by mapping tables to nodes and relationships

  3. Run the import after each stage and reviewing the data using the Query tool

Northwind Dataset

The Northwind dataset contains data about a fictional company called Northwind Traders, which imports and exports specialty foods from around the world.

The dataset contains tables for Customers, Orders, Products, Categories, and Employees.

mermaid
Northwind Relational Database Schema
erDiagram
    CATEGORIES {
        int categoryID PK
        string categoryName
        string etc
    }
    
    CUSTOMERS {
        string customerID PK
        string companyName
        string etc
    }
    
    EMPLOYEES {
        int employeeID PK
        string firstName
        string lastName
        int reportsTo FK
        string etc
    }
    
    PRODUCTS {
        int productID PK
        string productName
        int supplierID FK
        int categoryID FK
        decimal unitPrice
        string etc
    }
    
    ORDERS {
        int orderID PK
        string customerID FK
        int employeeID FK
        datetime orderDate
        string etc
    }
    
    ORDER_DETAILS {
        int orderID FK
        int productID FK
        decimal unitPrice
        int quantity
    }
    
    SUPPLIERS {
        int supplierID PK
        string companyName
        string etc
    }
    
    SHIPPERS {
        int shipperID PK
        string companyName
        string etc
    }
    
    REGIONS {
        int regionID PK
        string regionDescription
    }
    
    TERRITORIES {
        string territoryID PK
        string territoryDescription
        int regionID FK
    }
    
    EMPLOYEE_TERRITORIES {
        int employeeID FK
        string territoryID FK
    }

    %% Relationships
    CATEGORIES ||--o{ PRODUCTS : "categorizes"
    SUPPLIERS ||--o{ PRODUCTS : "supplies"
    CUSTOMERS ||--o{ ORDERS : "places"
    EMPLOYEES ||--o{ ORDERS : "handles"
    EMPLOYEES ||--o{ EMPLOYEES : "reports to"
    SHIPPERS ||--o{ ORDERS : "ships"
    ORDERS ||--o{ ORDER_DETAILS : "contains"
    PRODUCTS ||--o{ ORDER_DETAILS : "included in"
    REGIONS ||--o{ TERRITORIES : "contains"
    EMPLOYEES ||--o{ EMPLOYEE_TERRITORIES : "assigned to"
    TERRITORIES ||--o{ EMPLOYEE_TERRITORIES : "covers"

Create a graph data model

Your task is to:

  1. Download the Northwind dataset

  2. Create a new graph data model in the Import tool

  3. Open the Northwind dataset

  4. Review the data source

  5. Run the import to create Customer nodes

Continue with the lesson to create the graph data model

Import the Northwind dataset

You need to download the Northwind dataset and create a new blank graph data model:

  1. Download the Northwind dataset

  2. Open the Import tool in Aura and select Graph Models.

    Open Import Tool →
    Aura Console - Import - Graph Models
  3. Create a new graph data model.

    Blank graph model in the Import tool
  4. Use the …​ menu to Open model (with data) and select the northwind-customer.zip file you downloaded.

    …​ menu - Open model with data
  5. You will see the tables (csv files) from the Northwind dataset in the left-hand panel, and a single Customer node in the graph data model.

    The northwind dataset, files and graph data model

Review the Data Source

Review the data source tables and try to identify:

  • What tables will become Node labels

  • The associated relationships between tables through their primary/foreign keys

  • What fields will become properties on nodes and relationships

The data source tables and fields

Customer node

The Customer node has already been created for you.

Select the node in the graph data model and review the data model in the right hand panel.

Selecting the customer and showing the data model details

You should be able to identify the following:

  • The node label - Customer.

  • The source table - customers.csv.

  • The node properties - the name, what data type is used, and what column from the source table is used for each property.

  • What property is used as the unique ID for the node label - customerId.

Run the import

Run the import to create the Customer nodes:

  1. Click Run Import

  2. Select your instance

    Dialogue to select the Aura instance to import into
  3. Enter your instance credentials

  4. A summary of the import will be displayed

    Import result summary showing 91 nodes loaded

Query the graph

You can view the customers in the graph using the Query tool.

Run the following query to return the Customer nodes:

cypher
Customer nodes
MATCH (c:Customer)
RETURN c
Result of the query showing the Customer nodes

Lesson Summary

In this lesson, you imported customer data from the Northwind dataset and started to build a graph data model.

In the next lesson, you will continue to build the graph data model by adding Order nodes and PURCHASED relationships between customers and orders.

Chatbot

How can I help you today?

Data Model

Your data model will appear here.