Summary
A derived sub-database is a copy of a database restricted to the patients of a cohort: Linkr copies its tables, keeping only those patients’ rows — and, if asked, only some tables and some variables —, with the ids replaced by pseudonyms. The result is a database like any other, standing on its own, that keeps a record of its origin — the parent database and the cohort’s criteria — and can therefore be rebuilt once the warehouse has changed. The copy runs on the server.
The need
A hospital warehouse holds every patient. A study concerns only a fraction of them: one ward, one period, one condition.
Working on the whole warehouse forces every analysis to remember the filter — and it only takes one that forgets to produce a wrong figure. A sub-database defines the scope once and materializes it: everything that queries it already works within the right scope, with the same tables and the same column names as the parent database. A query written for one works on the other.
Not the same thing as a cohort
A cohort is a list of patients, used as a filter by analyses. A sub-database is a complete database — the parent database’s tables, restricted to those patients —, which you query, explore and link to projects like any other database.
Deriving a database
A derivation starts from a cohort of the database itself — not a project cohort.
Open the database’s cohorts
In Data Warehouse › Databases, open the parent database, then its Cohorts tab.
Build the cohort
With the usual criteria builder — see Cohorts —, at Patient, Hospitalization or Unit stay level.
Click Derive
The Derive button, in the builder’s toolbar, opens the Derive a database from this cohort dialog.
When the button is missing, or derives nothing
- It only exists in server mode: the copy is written by the server, into a database it manages. See Deployment modes.
- A cohort at Event level cannot be derived: it has no single id to filter the tables on.
- The database’s schema must say where its patients are — see Mapping a schema.
- The cohort must be defined by its criteria, not by hand-written SQL; unsaved edited SQL disables the button.
The Derive dialog
Derive a database from this cohort
Copy this database’s tables, keeping only what the project needs of “Septic shock”. The copy stands on its own: it does not read this database.
The dialog has three tabs: Destination (where the copy is written), Content (what it keeps) and Pseudonymisation (how the ids are replaced). The settings are remembered per cohort: reopening the dialog starts from the last ones.
Destination
- Already derived into — the derivations already made from this cohort, with their date and patient count. Rebuild makes one again with the cohort’s current criteria and the settings it was built with, replacing its content.
- Derive into — a new database, or a schema in an existing database (see below).
A new DuckDB database
The filtered tables are written into a separate database.
You give it a Name and a Location — Linkr’s data folder, or a folder on the server. Nothing is written into the parent database: this is the path that works everywhere, read-only warehouses included.
A SQL schema in an existing database
The filtered tables live in a new schema of a database that accepts writes.
A DuckDB database Linkr created, or a PostgreSQL, SQL Server, Doris or Oracle database whose settings tick Allow Linkr to write into this database. You choose the SQL schema name (lowercase letters, digits and underscores); Also add it as a database makes it appear in the list of databases. Linkr never changes the existing tables.
Depending on the target database’s engine:
| Engine | What the derivation creates | With which account |
|---|---|---|
| PostgreSQL | a new schema | your usual account, which needs the CREATE right |
| SQL Server | a new schema | a write account, separate from your read account (CREATE SCHEMA and CREATE TABLE rights) |
| Doris | a new Doris database; the rows are sent by Stream Load, on the connection’s Stream Load port (8030 by default) | a write account (CREATE and LOAD rights) |
| Oracle | nothing: in Oracle, a schema is a user. An administrator creates an empty schema for the derivation, and you give its name | a write account that can create tables and load rows in it |
The write account is asked for at the first derivation into the database, tested, then kept encrypted with your other accounts. The account Linkr reads the database with stays read-only. See Databases for the connection and its accounts.
Content
The principle is to copy only what the project needs.
- Individuals — which rows each table keeps. The cohort’s level keeps only what matched; a wider one keeps the rest of the record of the same patients. For a stay-level cohort: The cohort’s stays (its level), or The cohort’s patients, all their stays.
- Variables — every one, or a list of concepts. An event table then keeps only the rows of those concepts (concept or source concept), and one holding none of them is created empty. Add the criteria’s concepts brings in, in one click, the concepts the cohort was built on.
- Tables — one checkbox per table, to decide which are copied. Each says how it will be filtered: on the patients, stays or unit stays kept, or copied whole when it holds no patient data (vocabulary, care sites). Tables without patient data ticks them all again; a full OMOP vocabulary takes several GB.
A greyed-out table, in red, is never copied: either the mapping reads it without a patient id column, or it carries an id (a unit stay’s, for instance) that the chosen level gives no way to filter.
Each table is filtered on the finest id it carries, without going below the level kept. For unit stays, a table with a unit-stay id keeps the cohort’s; a table with only a hospital-stay id keeps the stays that contain them; a table with only the patient id keeps the patients.
Pseudonymisation
Pseudonymise the identifiers is ticked by default: every patient, stay and unit-stay id is replaced, in every table, by a pseudonym drawn for this database alone. This is what health-data rules ask of each project’s data — in France, the CNIL referential for health data warehouses. Replaced columns lists the columns concerned in the ticked tables.
- Method — Keyed hash (HMAC-SHA-256): the pseudonym is computed from the id with a secret key; with the same key, a rebuild gives the same pseudonyms. Random draw: a secure generator draws new ones at each build.
- Keep the key in Linkr — the key is encrypted on the server and never shown. Without it, each rebuild draws new pseudonyms.
- Pseudonyms — to follow a cohort over several databases, draw with the key of an earlier derivation: one patient then has one pseudonym in both.
- Correspondence table — the table linking each pseudonym to its id, for re-identification (a patient exercising their rights, an emergency). It is written into another database than the derived one, which never holds it, under the schema and table of your choice.
- Birth date — the precision the birth dates keep: Year only, Year and month (the default) or Full date, rarely needed (studies of infants under two).
Pseudonyms that can no longer be linked back
With neither a kept key nor a correspondence table — or a random draw without a correspondence —, the pseudonyms can never be linked back to the patients, and each rebuild draws new ones. The dialog says so before the copy starts.
Derive starts the copy as a server job, followed in the jobs panel at the bottom of the page, where it can also be stopped. For a new database, Linkr opens it straight away: it reads “Being set up” until the copy ends, then connects on its own. On a large warehouse, count minutes.
What the sub-database becomes
A database like any other: it appears in the list of databases, with its statistics, its schema browser, its parent’s mapping, and it links to projects. Its Overview tab also carries a Derived from a cohort card.
Derived from a cohort
Rebuild it from the criteria recorded here, against the database it was derived from.
That is what lets you answer, six months later, the question that always comes up: what exactly is in there?
Rebuild, on that card, replaces the tables with a new copy of the parent database, filtered on the criteria recorded when it was built — not on those the cohort may have since. It is the thing to do once the warehouse has been updated. The parent database must be in the same workspace, and connected; otherwise the card says so.
Two “Rebuild” buttons, two sets of criteria
From the sub-database’s card, you rebuild with the criteria frozen in its provenance: same scope, fresh data. From the cohort’s Derive dialog, you rebuild with its current criteria: the scope follows the cohort.
Deleting a sub-database offers to delete what Linkr created for it too: its file, or the SQL schema and its tables. Exported, it carries its provenance — and, like any database, never its data: on another instance, the card still names the parent database, but a rebuild is only possible where that one exists.
From an AI assistant
The MCP server exposes the same function: list_database_cohorts lists a database’s cohorts, plan_cohort_derivation shows the table-by-table plan without writing anything, and derive_database_from_cohort starts the copy, with the dialog’s settings and the same defaults (pseudonymised, birth dates to the month). It returns at once with the job’s id, which the assistant then follows to the new database. A write account is always entered in Linkr, never in the conversation.
And in browser mode?
Derivation does not exist there. Two approaches cover part of the need: a cohort, which defines the scope once and serves as a filter for analyses, or an ETL pipeline, where you write the filtering queries yourself, from a source database to a target one.
Going further
- Cohorts — the criteria builder a derivation starts from.
- Databases — what a sub-database is once built, and allowing writes into a PostgreSQL, SQL Server, Doris or Oracle database.
- ETL pipelines — for a transformation derivation cannot do.