Quilt·
Lesson 2 of 7

LINK — draw a typed relationship

LINK says: this cell relates to that cell in this way. Like drawing an arrow on a whiteboard, except the arrow has a label and the whole graph is recorded in the journal.

01The shape of LINK

LINK takes three arguments: a from-cell, a to-cell, and a relationship name (the type of the arrow). The arrow is recorded in the journal. The cells are auto-created if they don't exist yet.

substrate.link("alice", "bob", "friend");
substrate.link("alice", "coworker", "worksAt");
// journal: [
//   { op: "BIND", id: "alice", value: undefined, t: 0 },
//   { op: "BIND", id: "bob", value: undefined, t: 0 },
//   { op: "LINK", id: "alice→bob", value: "friend", t: 0 },
//   { op: "BIND", id: "coworker", value: undefined, t: 0 },
//   { op: "LINK", id: "alice→coworker", value: "worksAt", t: 0 }
// ]

02Try it

lesson-2.js
Journal · cells: 0 · links: 0

03The law: transitivity

LINKS of the same type are transitive. If Alice is a friend of Bob, and Bob is a friend of Carol, then Alice is a friend of Carol. The transitivity is automatic — you don't have to write the third link. Query the graph with follow(from, rel, hops) and the substrate does the rest.

This is how social networks, dependency graphs, file systems, and even knowledge graphs work. The substrate gives you transitivity for free, because it's a law, not a feature.

04What you can build with BIND + LINK

A knowledge graph. A social network. A file system. A database schema. All of these are cells with links. The substrate doesn't know about any of these — it just knows about BIND and LINK, and the rest is up to you.

05Next

So far we've only recorded facts. Let's actually do something. Lesson 3: EFFECT →