Skip to content
CMO & CTO
CMO & CTO

Closing the Bridge Between Marketing and Technology, By Luis Fernandez

  • Digital Experience
    • Experience Strategy
    • Experience-Driven Commerce
    • Multi-Channel Experience
    • Personalization & Targeting
    • SEO & Performance
    • User Journey & Behavior
  • Marketing Technologies
    • Analytics & Measurement
    • Content Management Systems
    • Customer Data Platforms
    • Digital Asset Management
    • Marketing Automation
    • MarTech Stack & Strategy
    • Technology Buying & ROI
  • Software Engineering
    • Software Engineering
    • Software Architecture
    • General Software
    • Development Practices
    • Productivity & Workflow
    • Code
    • Engineering Management
    • Business of Software
    • Code
    • Digital Transformation
    • Systems Thinking
    • Technical Implementation
  • About
CMO & CTO

Closing the Bridge Between Marketing and Technology, By Luis Fernandez

Querying Graphs: Cypher Patterns for Product Teams

Posted on February 19, 2012 By Luis Fernandez

“When everything looks like a table, you write joins. When everything looks like a graph, you write stories.”

Someone who shipped features on a Friday night

Cypher is making the rounds in meetups and repo readme files, and if your team is poking at Neo4j this weekend, you are not alone. With DynamoDB just out of the oven and everyone talking about NoSQL choices, a lot of product folks are asking a simple question. What makes a graph database worth adding to the stack?

A story from the backlog

We were trying to ship a small but sticky feature. Show people items their friends liked, but avoid repeats, boost by freshness, and keep it fast on mobile. The relational model groaned. We had tables for users, friendships, likes, items, and a salad of join tables. The query plan looked like a subway map. Caching helped for a minute, then the cache went cold the moment someone new liked something. We were shaving yaks with cron jobs.

We tried a document store to make fan out cheaper. It helped with writes and feeds, but the minute we asked a cross cut question like who is two steps away that cares about this item, we were back to custom code. That is when the graph idea clicked. Relationships first. Data that looks like our whiteboard. And a query language for patterns instead of contortions.

Enter Cypher query language. You sketch a shape of connections and it brings back matches. You can read it like a sentence. It feels close to how PMs explain a feature during standup. That is the magical bit for a team. Less translation. Fewer surprises.

Why graphs click for product work

Look around. Pinterest boards are exploding. Twitter conversations fork and weave. Spotify lists and follows tie people to tracks and artists. Your app has the same bones. Users connect to content and to each other. Those connections are where discovery, trust, and growth live. A graph database makes those links a first class thing.

With Neo4j you do not wrestle with cascading joins. You traverse. You say start at this user, walk to their friends, now to items those friends liked, filter by time and score, and stop when you have enough. And because the relationships are stored as pointers on disk, the walk stays snappy even when your node degree grows.

For a product team, that means you can ship a recommender, a people you may know module, or a simple trust based spam check without inventing a custom graph engine inside your app. Cypher queries give you a vocabulary for these moves in a way your designer can read. It is less black box.

Deep dive 1: Neighbor expansion for recommendations

Call this pattern friends of friends who like the same things. Start at a user. Walk to the items they liked. From those items, walk to other users who liked them. From those users, walk back to items the first user has not touched. Tally by frequency, bump by freshness, and exclude the obvious duplicates. This is the bread and butter for a recommendation engine with a social flavor.

Key moves in Cypher speak. Use a variable length hop to capture one or two steps where needed. Keep relationship directions clear so you do not circle in place. Apply a WHERE style filter early to cut dead branches. Use aggregation to count overlaps and then order by that score. Limit hard to keep the result set lean for the UI.

Product tip. Bias toward recency by storing a timestamp on the like relationship and mixing a time decay into your score. That lets you surface what is happening now without throwing out long tail gems. If you want diversity, include a simple category or tag hop and spread picks across it so the list does not look like five clones.

Deep dive 2: Path finding with guardrails

Shortest path is a classic, but most product questions want the shortest interesting path with rules. Think about onboarding hints like who can make a warm intro between two users. Or support flows like what is the lightest touch route from a bug report to the engineer who last touched the code. In Cypher you describe a path with a length range, add a few relationship types that are allowed, and then filter on nodes you do not want to cross, like blocked users or private groups.

Performance moves matter. Cap the maximum depth. Keep direction where the concept is directional, like follows. If you need symmetry, make it explicit rather than scanning both sides. When in doubt, split a giant query into two stages, stash a set of candidate node ids in your app layer or a temp index, then finish the walk. That keeps memory use predictable and keeps your page times happy.

This pattern is not just for social. It works for content graphs too. Chapters to sections to topics to authors. Or for fraud defense. Payment goes to device goes to IP goes to other payments. You can ask did this new payment land inside a three step radius of a known bad cluster. Same move, different nouns.

Deep dive 3: Permissions and feature flags as relationships

We tend to hide access checks in code. In a graph you can make it visible. Model users, teams, roles, and features as nodes. Connect users to teams, teams to roles, and roles to features. Add a rollout group node for a new feature and connect a few teams to it. Now your access check is a small pattern. If a path exists from the user to the feature through any approved route, let it through. If not, show the old UI.

The win here is clarity. PMs can reason about who has what without reading a switch statement. You can also answer questions like which teams would gain access if we promote this feature from private beta to public. That is a short traversal with a count, not a spreadsheet hunt.

Index practicalities. In today’s Neo4j builds you will want an index on stable node properties like user id or team slug so you can anchor your pattern fast. The auto index feature works well for this. Once you have your starting node, relationships do the heavy lifting.

What will not age

Tech stacks come and go. We all remember the great migration from pure LAMP to a mix of queues and stores. Right now everyone is picking between column families, key value stores, and documents. Graphs earn a spot when your product questions are about who is connected to what and how that connection shapes the next screen.

Cypher makes that conversation concrete. You describe shapes, not loops of code. That lets PMs, designers, and engineers share the same mental model. If your app is pushing social features, discovery, or trust signals, give graphs a fair run before you roll your own traversal layer.

Start simple. One feature. One graphy query. Measure the click lift or the fraud drop. If the win is there, grow it. If not, you learned something true about your data. Either way, you get closer to the story your product is trying to tell. And that is the whole point.

Engineering Management Software Engineering

Post navigation

Previous post
Next post
  • Digital Experience (94)
    • Experience Strategy (19)
    • Experience-Driven Commerce (5)
    • Multi-Channel Experience (9)
    • Personalization & Targeting (21)
    • SEO & Performance (10)
  • Marketing Technologies (92)
    • Analytics & Measurement (14)
    • Content Management Systems (45)
    • Customer Data Platforms (4)
    • Digital Asset Management (8)
    • Marketing Automation (6)
    • MarTech Stack & Strategy (10)
    • Technology Buying & ROI (3)
  • Software Engineering (310)
    • Business of Software (20)
    • Code (30)
    • Development Practices (52)
    • Digital Transformation (21)
    • Engineering Management (25)
    • General Software (82)
    • Productivity & Workflow (30)
    • Software Architecture (85)
    • Technical Implementation (23)
  • 2025 (12)
  • 2024 (8)
  • 2023 (18)
  • 2022 (13)
  • 2021 (3)
  • 2020 (8)
  • 2019 (8)
  • 2018 (23)
  • 2017 (17)
  • 2016 (40)
  • 2015 (37)
  • 2014 (25)
  • 2013 (28)
  • 2012 (24)
  • 2011 (30)
  • 2010 (42)
  • 2009 (25)
  • 2008 (13)
  • 2007 (33)
  • 2006 (26)

Ab Testing Adobe Adobe Analytics Adobe Target AEM agile-methodologies Analytics architecture-patterns CDP CMS coding-practices content-marketing Content Supply Chain Conversion Optimization Core Web Vitals customer-education Customer Data Platform Customer Experience Customer Journey DAM Data Layer Data Unification documentation DXP Individualization java Martech metrics mobile-development Mobile First Multichannel Omnichannel Personalization product-strategy project-management Responsive Design Search Engine Optimization Segmentation seo spring Targeting Tracking user-experience User Journey web-development

©2025 CMO & CTO | WordPress Theme by SuperbThemes