Import

Introduction

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

You will need to:

  1. Download the Northwind dataset

  2. Create a new graph data model

  3. Open the Northwind dataset in the Import tool

  4. Map the tables to the graph data model

  5. Run the import

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"
mermaid
Northwind Relational Database Schema
erDiagram
    CATEGORIES {
        int categoryID PK
        string categoryName
        string description
        blob picture
    }
    
    CUSTOMERS {
        string customerID PK
        string companyName
        string contactName
        string contactTitle
        string address
        string city
        string region
        string postalCode
        string country
        string phone
        string fax
    }
    
    EMPLOYEES {
        int employeeID PK
        string lastName
        string firstName
        string title
        string titleOfCourtesy
        datetime birthDate
        datetime hireDate
        string address
        string city
        string region
        string postalCode
        string country
        string homePhone
        string extension
        blob photo
        text notes
        int reportsTo FK
        string photoPath
    }
    
    PRODUCTS {
        int productID PK
        string productName
        int supplierID FK
        int categoryID FK
        string quantityPerUnit
        decimal unitPrice
        int unitsInStock
        int unitsOnOrder
        int reorderLevel
        bit discontinued
    }
    
    ORDERS {
        int orderID PK
        string customerID FK
        int employeeID FK
        datetime orderDate
        datetime requiredDate
        datetime shippedDate
        int shipVia FK
        decimal freight
        string shipName
        string shipAddress
        string shipCity
        string shipRegion
        string shipPostalCode
        string shipCountry
    }
    
    ORDER_DETAILS {
        int orderID FK
        int productID FK
        decimal unitPrice
        int quantity
        decimal discount
    }
    
    SUPPLIERS {
        int supplierID PK
        string companyName
        string contactName
        string contactTitle
        string address
        string city
        string region
        string postalCode
        string country
        string phone
        string fax
        string homePage
    }
    
    SHIPPERS {
        int shipperID PK
        string companyName
        string phone
    }
    
    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

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.

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

  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:

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?