Congratulations and Next Steps

Congratulations on completing "Importing Relational Data into Neo4j".

You have worked through the entire process of migrating data from a relational database into Neo4j:

  • Analyzing relational schemas and understanding table relationships

  • Designing a graph data model from relational tables

  • Mapping foreign keys to graph relationships

  • Planning constraints and indexes for data integrity

  • Using the Neo4j Data Importer to import data

  • Validating and querying your imported graph

Apply This to Your Own Relational Data

If you want to migrate your own relational database (PostgreSQL, BigQuery, Snowflake, or any SQL source) to Neo4j, follow these steps:

Phase 1: Analyze Your Schema

The following SQL uses standard information_schema; adapt syntax as needed for your database (PostgreSQL, MySQL, SQL Server, BigQuery, etc.).

  1. Document your tables - List all tables in your database using:

    sql
    SELECT table_name
    FROM information_schema.tables
    WHERE table_schema = 'public';
  2. Identify foreign keys - Find all relationships between tables:

    sql
    SELECT
        tc.table_name AS source_table,
        kcu.column_name AS foreign_key,
        ccu.table_name AS target_table,
        ccu.column_name AS target_column
    FROM information_schema.table_constraints tc
    JOIN information_schema.key_column_usage kcu
        ON tc.constraint_name = kcu.constraint_name
    JOIN information_schema.constraint_column_usage ccu
        ON ccu.constraint_name = tc.constraint_name
    WHERE tc.constraint_type = 'FOREIGN KEY';
  3. Categorize your tables using the framework from Lesson 2.2:

    • Entity tables become nodes

    • Junction tables become relationships

    • Lookup tables become properties or small nodes

    • Audit tables: evaluate if needed in graph

Phase 2: Design Your Graph Model

  1. Create a visual model using Arrows.app

  2. Define node labels — Use singular PascalCase names such as Customer and Order

  3. Define relationship types — Use UPPER_SNAKE_CASE verbs such as PLACED and CONTAINS

  4. Plan properties - Decide which columns become properties and apply camelCase naming

  5. Identify constraints - Determine unique identifiers for each node type

Phase 3: Prepare Your Import

  1. Create constraints first - Adapt the constraint script from Lesson 2.5:

    cypher
    CREATE CONSTRAINT your_node_id IF NOT EXISTS
    FOR (n:YourLabel) REQUIRE n.yourID IS UNIQUE;
  2. Plan import order - Follow the dependency chain:

    1. Independent nodes without foreign keys

    2. Dependent nodes that reference other nodes

    3. Relationships

Phase 4: Execute the Import

  1. Connect your relational database or upload CSV files to the Data Importer; see Lesson 1.2

  2. Map tables to nodes following your graph model design

  3. Set unique identifiers for each node type

  4. Create relationships by mapping foreign key columns

  5. Run the import and monitor for errors

Phase 5: Validate Your Import

  1. Run node count queries - Compare with source table counts

  2. Run relationship count queries - Compare with foreign key counts

  3. Check for orphan nodes - Find nodes missing expected relationships

  4. Spot-check sample records - Verify data accuracy

  5. Test your use case queries - Confirm the graph model supports your requirements

Quick Reference Checklist

Use this checklist when migrating your own data:

  • Schema documented: tables, columns, foreign keys

  • Tables categorized: entity, junction, lookup, audit

  • Graph model designed in Arrows.app

  • Node labels and relationship types defined

  • Constraints planned for all node types

  • Import order determined

  • Relational source connected or CSV files uploaded

  • Nodes imported with unique identifiers

  • Relationships created from foreign keys

  • Validation queries executed

  • Sample data verified

Continue Your Learning Journey

You can continue your Neo4j learning on GraphAcademy with the following courses:

Additional Resources

You may also find these resources helpful:

Lessons to Bookmark

The following lessons contain reference material you will return to in future projects. Bookmark them now:

  • Lesson 1.1: Comparing relational and graph data - The relational-to-graph mapping table

  • Lesson 2.2: Identifying Nodes from Tables - The mapping table and misconception corrections

  • Lesson 2.3: Mapping Relationships - The four common misconceptions about foreign key transformation

  • Lesson 2.5: Planning Constraints and Indexes - Constraint and index creation scripts

  • Lesson 3.5: Handling Complex Data Scenarios - The nine best practices checklist

  • Lesson 4.1: Validating Imported Data — The validation test plan and queries

  • Lesson 4.2: Validate Your Import — The hands-on validation challenge

  • Lesson 4.3: SQL and Cypher: Query Efficiency Comparison — The performance comparison summary table

When working in Neo4j Aura, organize your saved queries using this folder structure. The numbered prefixes indicate execution order:

01-Setup-Constraints/
02-Setup-Indexes/
03-Import-Independent-Nodes/
04-Import-Dependent-Nodes/
05-Import-Transaction-Nodes/
06-Create-Relationships/
Validation-01-Node-Counts/
    count-all-nodes.cypher
    count-customers.cypher
    count-orders.cypher
    count-products.cypher
Validation-02-Relationship-Counts/
    count-all-relationships.cypher
    count-placed.cypher
    count-contains.cypher
Validation-03-Referential-Integrity/
    find-orphan-orders.cypher
    find-orphan-products.cypher
    find-employees-without-manager.cypher
Validation-04-Property-Checks/
    check-date-types.cypher
    check-empty-strings.cypher
    check-numeric-types.cypher
Validation-05-Sample-Data/
    validate-customer-alfki.cypher
    validate-order-10248.cypher
Validation-06-Constraints/
    show-constraints.cypher
    test-constraint-enforcement.cypher
Query-Patterns-Simple/
Query-Patterns-Multi-Hop/
Query-Patterns-Hierarchical/
Query-Patterns-Matching/
Query-Patterns-Aggregation/
Maintenance-Cleanup/
Maintenance-Monitoring/
Admin-Verification/

This structure applies to any import project. Adapt the specific queries for your source data.

Check Your Understanding

Course Completion

Which of the following are benefits of migrating relational data to a graph database? Select all that apply.

  • ✓ Relationships become explicit and first-class citizens

  • ✓ Complex JOIN queries are replaced by simple traversals

  • ✓ The data model can evolve more flexibly

  • ❏ All data must be normalized to third normal form

Hint

Graph databases store relationships explicitly and support constant-time traversal; relational databases use foreign keys and JOINs computed at query time. Benefits include explicit relationships, traversals replacing complex JOINs, and a more flexible schema.

Solution

The benefits of migrating to a graph database include:

  • Relationships become explicit - Unlike foreign keys, graph relationships are stored directly and can have properties

  • Simple traversals replace JOINs - Following relationships is a constant-time operation

  • Flexible schema - Graph databases allow the model to evolve without rigid schema changes

Graph databases do not require normalization - in fact, some denormalization can improve query performance.

Summary

This course has provided the foundational skills for migrating relational data into Neo4j. You can now analyze relational schemas, design appropriate graph models, execute imports, and validate the results. These skills apply to any relational-to-graph migration project, regardless of the source database or domain.

Chatbot

How can I help you today?