Databases

A database is a live collection of the notes that match its conditions. Each note is a row, its properties are the columns, and nothing is copied.

In Terra, a database is a set of conditions, such as "every note in projects/field-guide" or "every note tagged #recipe", and the live list of notes that match them. Each note is a row and its properties are the columns. Nothing is copied: edit a cell and you've edited the note; move a note out of the folder and it leaves the database. A note belongs to every database whose conditions it matches.

If you know Obsidian Bases, it's the same idea. Unlike a Notion database, the rows aren't stored inside the database: they're ordinary Markdown notes in your folders. For a worked example, see Run a project.

Terra's sidebar lists All notes, Tasks, Calendar and Sprouts under System, then Inbox, Today, Favorites, Trash, References and Links under Databases, and Field guide launch under User. The Field guide launch table shows ten notes with status, owner, start, due and effort columns.
Built-in databases sit under System and Databases; the ones you make are listed under User. This one collects every note in a project folder.

How a database works

PartWhat it isWhere you change it
ConditionsThe rule for which notes belong: a folder, a tag, a property value and so onView preferences › Database
RowsThe notes that match, kept up to date as your notes changeIn the notes themselves
ColumnsThe notes' properties, plus any computed properties you addThe table header, or a note's properties
ViewsSaved ways to look at the rows: a table, a board, a calendar, a chartThe view menu in the database's header

A database you make is one small file, .terra/databases/<id>.json in your Library, holding its name, conditions and views. Your notes stay where they are. Conditions skip notes in the Trash; only Trash shows those.

Built-in databases

Every Library comes with these. You can give each one its own views, pin it to the rail or change its icon, but you can't rename or delete it. To tidy the sidebar, right-click one and choose Hide; Hidden in the same menu brings it back.

DatabaseSidebar sectionWhat it collects
All notesSystemEvery note in the Library
TasksSystemEvery checkbox task in your notes, as a board by status. Its rows are tasks, not notes. See Tasks.
CalendarSystemNotes placed on a calendar by date, with task due dates and events from connected calendars. See Calendar.
SproutsSystemEvery Sprout in your notes, as a board grouped by kind
InboxDatabasesNotes in the Inbox folder, where new notes and captures land
TodayDatabasesNotes edited today
FavoritesDatabasesNotes tagged #favorite
TrashDatabasesDeleted notes, waiting in the Trash folder
ReferencesDatabasesNotes with bibliographic details, such as the papers and books you cite
LinksDatabasesWeb pages you've saved

Graph in the System section is a view of All notes. Templates and Ask sit there too, but they aren't databases. Today starts its day at midnight UTC, so west of Greenwich it turns over during your evening.

Folders, tags and options open as databases

Click a folder under Folders and it opens as a database of the notes in that folder and its subfolders, with saved views like any other: a folder can be a board or a calendar. Two more things open the same way:

  • A #tag in a note: click it to open its tag page, every note with that tag.
  • An option of a select or status property: in Tools › Property Manager…, click the option and choose Open database to see every note that has it.

You can't change what these collect, and computed properties need a database you made.

Make a database

  1. In the sidebar, point at Databases and click + (New database).
  2. Type a name.
  3. Click + (Add condition) and build a condition from a field, a test and a value, such as Folder · starts with · projects/field-guide.
  4. Add more conditions if you need them. Once there are two, click the And beside them to switch to Or or Not. Click { } (Add group) for a nested set.
  5. Click Save, or press Return in the name field.
The New database popover named Field guide launch, with two conditions joined by Or: Folder starts with projects/field-guide, and tags contains field-guide.
With Or, a note belongs if it matches either condition: it's in the project folder, or it's tagged field-guide.

The database opens as a table with View preferences beside it, ready for its first view, and it's listed under Databases › User. A database with no conditions collects every note.

File › New Database and New… › New database in the toolbar skip the popover. They make a database called Untitled that collects every note; rename it from the sidebar and add conditions on its Database tab.

Conditions can use Title, Status, Tags, Folder, Type, Source, Updated, Created, every property in your Library, and Note Body, the text of the note. The tests depend on the field's type; Filter, sort and group lists them. Good to know:

  • Tests ignore capitals.
  • A note's Folder is the folder that holds it, such as projects/field-guide. is matches that folder only; starts with takes in its subfolders too. Notes at the top of the Library have no folder.
  • Note Body reads every note's text, so it's the slowest test. Terra reads at most 5,000 notes for it.

Change what a database collects

Open the database, click View preferences at the right end of its header, and choose the Database tab.

View preferences open on the Database tab: Match by Filter, one condition Folder starts with projects/field-guide, and the line 10 notes · 4 ms.
The Database tab holds the conditions. The line under them counts the notes that match and how long the match took.
  • Match by switches between Filter, the conditions, and SQL, a SELECT statement that picks the notes. See Queries.
  • Changes save themselves after a moment. They aren't part of Save view.
  • These conditions decide which notes belong. A view's Filters only hide rows in that one view; see Filter, sort and group.

The Database tab appears only on databases you made. Built-ins and folders keep their fixed rules.

Child databases

Some built-ins can hold databases of their own: a narrower slice that opens like its parent and keeps its own views.

  1. Right-click Tasks, Calendar or Sprouts under System, or Links or References under Databases.
  2. Choose the first item: New task database, New calendar database, New sprout database, New link database or New reference database.
  3. Type a Database name and click Create. The new database sits under its parent in the sidebar.
The right-click menu on Links: New link database, New note, New from template…, Pin to rail, Change icon and Hide.
Built-ins that take children offer them as the first item of their right-click menu.
  • A child of Calendar, Links or References starts with all of its parent's notes. Narrow it with conditions on its Database tab: a To read child of Links that keeps pages tagged #to-read, for example.
  • A child of Tasks or Sprouts opens as a board. Pick the notes it reads with Sources in its header. See Tasks.
  • Children go one level deep, and databases you make can't have children.

Favorites works differently. Right-click it and choose New favorites collection for a hand-picked list instead of a rule, then add notes from a note's right-click Favorite menu. Collections can hold collections.

Add a note to a database

To add a note you already have, give it what the database collects: move it into the folder, add the tag or set the property. It appears straight away.

To start a new note from a database:

  • Point at a database you made in the sidebar and click New note here, or right-click it and choose New note.
  • On a Board view, click + Add note at the foot of a column. The note takes that column's value.
Starting fromThe new note goes to
A folderThat folder
A database you madeYour Inbox folder, with the column's value if you used a board

Rename or delete a database

Right-click a database you made and choose Rename (type the new Database name, then click Rename) or Delete. Deleting asks first and reminds you: "Notes are kept; only the database is removed." Deleting a database's last view deletes the database too, with an Undo in the message that follows. Built-ins can only be hidden.

Put a database in a note

A database can sit inside any note, such as a weekly review, a project page or a dashboard, and it stays live there.

  1. On an empty line, type /database and press Return.
  2. In Insert database, pick a database, or click New database to make one.
A note with a sentence followed by an embedded database: the All work header with its view menu and controls, then a table of field-guide work items with status, owner and due.
A database inside a note, with the same header as the database itself.

The block is the database, not a copy: change a status in it and the note changes; change the view's filters or sorting and the database's view changes too. In the note's file, the block is one line that points at the database by its id:

Where the launch stands on Friday. The table below is the live database, not a copy.

<!-- terra:inline-db eyJkYXRhYmFzZUlkIjoiMDFKUThaQjRLMk03WDlUM1I1VjZXOFkwQzEiLCJtb2RlIjoibGlua2VkIiwidmlld092ZXJyaWRlIjpudWxsfQ== -->

Other Markdown apps, Obsidian included, show nothing for that comment. If the database is deleted, the block reads Database not found with Pick another and Remove.