CSE Roadmap

Specialist tier · about 2 hours · 5 parts

Part 3 of 5 · 2 min read

Why highly connected data fits a graph

A graph has no fixed shape for what can connect to what, so adding a new kind of relationship never requires redesigning the schema.

Think of that corkboard again, now with hundreds of photos: authors, books, customers, reviews. New string gets added between any two photos as a new connection is discovered. No one needs to redesign the corkboard first.

In plain words: a relational schema has to decide, in advance, which tables can reference which other tables through foreign keys. A document model nests one-to-many relationships well, but struggles once relationships run in many directions at once. A graph has no such restriction. Any vertex can be connected to any other vertex by an edge, with no schema declaring in advance which kinds of vertices are allowed to connect. Adding an entirely new kind of relationship, say a customer who follows an author, means adding a new edge label. It does not require altering any table or restructuring any document.

A worked example. The bookstore starts with authors connected to books by WROTE edges. Later, a recommendation feature is added: customers connected to other customers by FOLLOWS edges, and customers connected to authors by FOLLOWS_AUTHOR edges. None of this requires changing how the original author-book edges are stored.

The key lines. No new SQL; the point is that a graph needs no schema change to add a new kind of edge, unlike a relational table needing a new foreign key column or a new join table.

Schema-free connections (in a graph)

A graph's schema-free connections mean any vertex can be linked to any other vertex by an edge, with no predeclared restriction on which vertex types may connect. A new kind of relationship is added as a new edge label, without altering any existing table or document structure.

Example: adding customer-follows-author edges to a graph that already holds author-wrote-book edges, with no change to how the existing edges are stored, is schema-free connections at work.