Property Graphs
Property Graphs
Understand nodes, relationships, properties, and labels
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
# Cell 1 — ParametersUSERNAME = "_FILL_ME_IN_" # Set your email before running# Cell 2 — Connectfrom graph_olap import GraphOLAPClientclient = GraphOLAPClient(username=USERNAME)
# Cell 3 — Provisionfrom notebook_setup import provisionpersonas, 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")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 dataresult = conn.query(""" MATCH (c:Customer) RETURN c.id AS name, c.bk_sectr AS sector LIMIT 5""")
result.show()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 APIschema = conn.get_schema()
print("Node labels in graph:")for label in schema.node_labels: print(f" {label}")Relationships
Connections between nodes
Relationships connect two nodes and always have:
- A direction — from a source node to a target node.
- A type — a label like
SHARES_ACCOUNTthat describes the connection. - 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 APIprint("Relationship types in graph:")for rel_type in schema.relationship_types: print(f" {rel_type}")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 noderesult = 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