Course contentsShow
← Computer Science
Lesson 1749 of 2,87239. NoSQL and Modern DatabasesFree lesson

Relationships and Edge Properties

Creating typed, directed relationships between nodes with properties, representing connections in data.

Relationships and Edge Properties

What you'll learn: How graph databases use typed, directed relationships with properties to represent rich connections between nodes.

What Are Relationships?

In a graph database, relationships (also called edges) connect two nodes and represent how they're related. Unlike relational databases where you must join tables to discover connections, graph relationships are first-class citizens — they're stored directly and efficiently.

Typed and Directed

Each relationship has a type that names the connection (like FRIENDS_WITH, PURCHASED, or MANAGES). Relationships are also directed, meaning they point from one node to another. The direction matters: Person A -[MANAGES]-> Person B is different from Person B -[MANAGES]-> Person A.

Think of relationships like labeled arrows on a whiteboard connecting sticky notes (nodes).

Properties on Relationships

Just like nodes have properties, relationships can too. These edge properties store metadata about the connection itself:

  • A PURCHASED relationship might have date, price, and quantity properties
  • A FRIENDS_WITH relationship might include since: "2015-03-20" and strength: 0.8

This is powerful: you're not just saying "these things are connected" — you're describing how and when they're connected.

Why This Matters

Relationship properties let you model real-world complexity naturally. Instead of creating extra junction tables (like in SQL), you attach relevant data directly to the connection. Querying becomes intuitive: "Find all products John purchased in 2023 where quantity > 5" maps directly to traversing PURCHASED relationships with specific property filters.

Key Takeaway: Graph databases model connections as typed, directed relationships that can carry their own properties, making complex interconnected data queries natural and performant.