Skip to content

Property Graphs

Tutorial

Property Graphs

Understand nodes, relationships, properties, and labels

20 min Beginner
CypherGraphsFundamentals

What You'll Learn

  • Graph Model - Nodes, relationships, and properties
  • Labels - Categorize nodes with labels
  • Relationship Types - Connect nodes with typed edges
  • Properties - Store data on nodes and relationships
Info:
Prerequisites
No prerequisites - start here!
# Cell 1 — Parameters
USERNAME = "_FILL_ME_IN_" # Set your email before running
# Cell 2 — Connect
from graph_olap import GraphOLAPClient
client = GraphOLAPClient(username=USERNAME)
# Cell 3 — Provision
from notebook_setup import provision
personas, conn = provision(USERNAME)
analyst = personas["analyst"]
admin = personas["admin"]
ops = personas["ops"]
client = analyst
print(f"Connected | {conn.query_scalar('MATCH (n) RETURN count(n)')} nodes")
1

What is a Property Graph?

Core concepts

A property graph stores data as:

  • Nodes (vertices) — entities like customers, accounts, or transactions.
  • Relationships (edges) — directed connections between nodes, e.g. SHARES_ACCOUNT.
  • Labels — categories that group nodes by type, e.g. Customer.
  • Properties — key-value pairs stored on both nodes and relationships, e.g. id, bk_sectr.

Unlike relational tables, a property graph makes connections first-class citizens. Traversing a relationship is a single pointer hop, no matter how large the graph is.

# Retrieve a few customer nodes to see the graph data
result = conn.query("""
MATCH (c:Customer)
RETURN c.id AS name, c.bk_sectr AS sector
LIMIT 5
""")
result.show()
2

Nodes and Labels

Entities in your graph

Every node carries one or more labels that describe its type. Labels let Cypher target specific kinds of nodes: MATCH (c:Customer) only matches nodes with the Customer label.

Use get_schema() to discover which labels exist in the loaded graph.

# Explore node labels via the schema API
schema = conn.get_schema()
print("Node labels in graph:")
for label in schema.node_labels:
print(f" {label}")
3

Relationships

Connections between nodes

Relationships connect two nodes and always have:

  1. A direction — from a source node to a target node.
  2. A type — a label like SHARES_ACCOUNT that describes the connection.
  3. Optional properties — key-value data on the edge itself.

In Cypher, relationships are written inside square brackets: (a)-[:SHARES_ACCOUNT]->(b).

# Explore relationship types via the schema API
print("Relationship types in graph:")
for rel_type in schema.relationship_types:
print(f" {rel_type}")
4

Properties

Data attributes

Properties are key-value pairs attached to nodes or relationships. They store the actual data — names, identifiers, sector codes, and so on.

Let’s fetch a single Customer node and inspect all its properties.

# Inspect the properties of a single node
result = conn.query("MATCH (c:Customer) RETURN c.id, c.bk_sectr, c.acct_stus LIMIT 1")
result.show()

Key Takeaways

  • A property graph has nodes (entities) connected by relationships (edges)
  • Labels categorize nodes (e.g. Customer)
  • Relationships have a direction and a type (e.g. SHARES_ACCOUNT)
  • Properties store key-value data on both nodes and relationships