Relations are the core concept that makes CodeDB more than a simple editor. They let you define typed connections between files, creating a knowledge graph of your codebase.
A relation connects a source file to a target file with a type. For example:
app.js imports utils.jsapi.py depends_on database.pyREADME.md documents main.gotest_auth.py tests auth.pyThere are several ways to add a relation:
You can use any relation type string. Common types include:
imports — file imports or includes anotherdepends_on — file depends on anotherextends — file extends or inherits from anothertests — test file for a source filedocuments — documentation for a filerelated_to — general associationcalls — file calls functions from anotherconfigures — configuration file for a moduleThe Relations panel at the bottom of the editor shows all connections for the active file:
Each relation shows the connected file name, relation type, and can be clicked to navigate to that file.
Relations can store optional metadata as key-value pairs. This is useful for adding context like version constraints, notes, or categories to a relationship.
Relations are stored in the relations table:
CREATE TABLE relations ( id INTEGER PRIMARY KEY, source_id INTEGER REFERENCES files(id), target_id INTEGER REFERENCES files(id), relation_type TEXT NOT NULL, metadata TEXT );
You can query relations directly in the Query Console.