Creating Relationships

In the previous lesson, you learned how to create nodes using the Data Importer. In this lesson, you will learn how to create relationships between nodes.

Creating Relationships in Data Importer

Relationships connect nodes and represent how data is connected. In the Northwind model, relationships include:

  • Customer -[:PLACED]→ Order

  • Order -[:CONTAINS]→ Product

  • Product -[:IN_CATEGORY]→ Category

  • Supplier -[:SUPPLIES]→ Product

Step 1: Create Nodes First

Ensure all node types exist first:

  1. Add all node labels: Customer, Order, Product, Category, Supplier, and others

  2. Map properties from CSV files

  3. Set unique identifiers for each node type

Step 2: Draw a Relationship

In the Data Importer canvas:

  1. Hover over the edge of the source node until you see the + icon

  2. Drag from the source node to the target node

  3. Release to create the relationship

Creating a relationship in Data Importer

Step 3: Configure the Relationship

In the Definition panel:

  1. Enter the relationship type such as PLACED, CONTAINS, or IN_CATEGORY

  2. Select the data source — the CSV file — that contains the relationship data

  3. Map the From ID - the column that matches the source node’s unique identifier

  4. Map the To ID - the column that matches the target node’s unique identifier

  5. Optionally map relationship properties from additional columns

Green checkmarks indicate valid mappings

The Data Importer shows a green checkmark when an element has been mapped correctly. If you see a warning, check that:

  • The ID columns match the unique identifiers on the nodes

  • The data types are compatible

  • The CSV file contains the expected columns

Step 4: Add Relationship Properties

Some relationships carry additional data. For example, the CONTAINS relationship between Order and Product includes:

  • quantity - how many units were ordered

  • unitPrice - the price at the time of order

  • discount - any discount applied

To add relationship properties:

  1. Select the relationship in the model

  2. Click Map from table

  3. Select the columns to include as properties

  4. Set appropriate data types

Example: Northwind Relationships

For the Northwind dataset, create these relationships:

From Relationship To Properties

Customer

PLACED

Order

(none)

Order

CONTAINS

Product

quantity, unitPrice, discount

Product

IN_CATEGORY

Category

(none)

Supplier

SUPPLIES

Product

(none)

Employee

PROCESSED

Order

(none)

Order

SHIPPED_BY

Shipper

(none)

Employee

REPORTS_TO

Employee

(none)

Importing Nodes and Relationships from a Single File

Northwind uses separate CSV files per table, but you often encounter denormalized or joined data where one file contains both node and relationship data.

Example: A ratings.csv file with movieId, userId, name, rating, timestamp can create both User nodes and RATED relationships to Movie nodes.

The process is the same as with multiple files:

  1. Upload the single CSV file to Data Importer

  2. Create the node label and relationship in the model

  3. Map the same file as the data source for both the node and the relationship

  4. Map node columns (e.g. userId, name) to the User node, and relationship columns (e.g. rating, timestamp) to the RATED relationship

  5. Set the Node ID mappings: From userId (User) and To movieId (Movie)

  6. Run the import

When the source combines entity and linkage data, Data Importer creates the nodes and relationships in one pass. Ensure the file has columns for both the node identifier and the relationship target identifier.

Verify Relationships

Verify relationships:

cypher
// Count relationships by type
MATCH ()-[r]->()
RETURN type(r) AS relationship, COUNT(*) AS count
ORDER BY count DESC
cypher
// Sample a specific relationship
MATCH (c:Customer)-[r:PLACED]->(o:Order)
RETURN c.companyName, o.orderID
LIMIT 5
cypher
// Check relationship properties
MATCH (o:Order)-[r:CONTAINS]->(p:Product)
RETURN o.orderID, p.productName, r.quantity, r.unitPrice
LIMIT 5

Using the Data Importer

With AuraDB, the Data Importer is integrated:

  1. Open your instance and click Import

  2. Design your model with nodes and relationships

  3. Click Run import to execute

Check Your Understanding

Relationship ID Mapping

When creating a relationship in the Data Importer, what must you map to connect two nodes?

  • ❏ The node labels

  • ❏ The relationship properties

  • ✓ The unique identifiers (IDs) of the source and target nodes

  • ❏ The CSV file name

Hint

Relationships connect nodes using their unique identifiers. The Data Importer needs to know which column in the CSV matches the ID on each node.

Solution

You must map the unique identifiers (IDs) of the source and target nodes. The Data Importer uses these IDs to find the correct nodes and create the relationship between them.

For example, to create a PLACED relationship between Customer and Order, you map:

  • From ID: The column containing customer IDs (matching Customer’s unique identifier)

  • To ID: The column containing order IDs (matching Order’s unique identifier)

Summary

In this lesson, you learned how to create relationships in the Data Importer by:

  • Drawing connections between nodes

  • Mapping ID columns to link nodes

  • Adding relationship properties

In the next lesson, you will learn how to handle complex data scenarios during import.

Chatbot

How can I help you today?