n8n data tables official
Use when working with n8n's built-in Data Tables, designing schemas, inserting/updating/upserting rows, deduping, or querying. Triggers on "Data Table", "data table", `n8n-nodes-base.dataTable`, "dedup", "idempotency", "lookup", "persistent state", "store across executions", or any schema design discussion inside n8n.
By- name:
- n8n-data-tables-official
- description:
- Use when working with n8n's built-in Data Tables, designing schemas, inserting/updating/upserting rows, deduping, or querying. Triggers on "Data Table", "data table", `n8n-nodes-base.dataTable`, "dedup", "idempotency", "lookup", "persistent state", "store across executions", or any schema design discussion inside n8n.
n8n Data Tables
Data Tables are n8n's built-in tabular storage: real tables inside the n8n instance with columns, types, rows, and CRUD via the dataTable node and data-table MCP tools.
Use them for local persistent state: lookup tables, recent events, per-session inventories, counters, idempotency tracking, dedup state when there's row-level logic or external visibility (plain "have I seen this value?" dedup belongs in the Remove Duplicates node). Small-to-moderate volume (tens of thousands of rows fine, millions belong in a real DB).
Non-negotiables
- System-managed columns + external IDs. Three columns auto-exist on every table:
id(bigserial),createdAt,updatedAt. Don't declare them increate_data_table(errors or shadows the system column). Don't write them on insert. For domain identifiers from outside (arxivId, stripeCustomerId, requestId), add a separate column and key dedup/lookup on that. - Only primitives in columns, nested data uses
string+_objectpostfix. No JSON/object/array column types exist. For nested data (arrays, parsed objects), use astringcolumn withJSON.stringify(...)on write andJSON.parse(...)on read. Mark the column with_object(e.g.,keyInsights_object). The postfix is the contract that tells readers to parse. Seereferences/SCHEMA_DESIGN.md.
Strong defaults
- Don't add a Set node before a Data Table node to modify fields. The Data Table node's per-column expression slots are just as powerful as Set fields, so the Set node is doing zero work the Data Table node can't do itself. (Same Set-node antipattern called out in
n8n-expressions-official.) - Match n8n's column casing: camelCase. The auto-managed columns are camelCase (
createdAt,updatedAt), so user columns read more cleanly when they match:arxivId,paperId,taxRate. Mixed casing in the same query (createdAt >= ... AND arxiv_id eq ...) reads as a typo. Keep the_objectpostfix on stringified-blob columns regardless (keyInsights_object), the underscore is a contract marker, not casing.<!-- TEMPORARY: remove when the data tables node quirk is fixed --> - Verify the
columnsparameter viaget_workflow_detailsafter create/update. The UI has a display quirk in manual mapping mode ("Currently no items exist" with no actual data loss). Checking the JSON confirms what's persisted. - Relational design works when the shape calls for it. For genuine parent-child data (papers → summaries, customers → orders), reference parents by
id, name columns explicitly (paperId,customerId), and enforce integrity in workflow logic. Don't force it on flat use cases (dedup, lookup, audit) where there's no relationship to model. - Storage format is not interface format. Parse
_objectfields before returning them from a sub-workflow. Callers should never receive stringified shells they have to parse themselves. Seereferences/SCHEMA_DESIGN.md"Storage format ≠ interface format".
The default columns
Every Data Table has these whether you declare them or not:
| Column | Type | Behavior |
|---|---|---|
id |
bigserial / number | Auto-incrementing primary key. n8n assigns on insert, and you can't write to it. Returned in the insert response. |
createdAt |
timestamp | Set automatically on insert. |
updatedAt |
timestamp | Refreshed automatically on each update. |
In practice:
- Don't declare them in
create_data_table. Already there. - Use them in queries without your own timestamp columns. "Created today":
createdAt >= '<today ISO>'. "Updated since last sync":updatedAt >= $('Last Sync').item.json.timestamp. - Don't use them as cross-system identifiers. Auto-
idis internal, and resets on table recreate or instance migration. For domain identifiers, use your own column.
Relational design when the shape calls for it
Data Tables don't enforce foreign keys, but you can still model parent-child data across tables when the data genuinely has that shape. The catch: integrity is your responsibility, not n8n's.
- Reference parent rows by
id. A child table holds the parent'sidin a column. - Document references in column names.
paperId,customerId,eventIdmake the relationship obvious. - Enforce integrity in workflow logic. Before inserting a child, look up the parent. Before deleting a parent, decide what happens to children (delete, orphan, archive). n8n won't cascade.
- Watch for stale references. Children pointing at deleted parents are silent bugs. Soft-delete, or run cleanup workflows.
For complex relational structure (3+ tables with joins, transactional writes), reach for an actual SQL DB.
Operations: which one for what
| Operation | When |
|---|---|
insert |
Always-add. New row, n8n assigns id. |
upsert |
"Add if new, update if exists." Needs a matchType and filter to decide existence. |
update |
"Modify rows matching this filter." No insert if no match. |
get |
Fetch rows matching a filter (returns 0+). Supports orderBy, limit, returnAll. |
deleteRows |
Remove rows matching a filter. |
rowExists / rowNotExists |
Boolean-style filter against incoming items. Common for dedup branching. |
For the full operation surface (filter syntax, matchType, sort patterns), see references/OPERATIONS.md.
The "Currently no items exist" UI quirk
When the SDK saves manual-mode column mappings (mappingMode: 'defineBelow'), the n8n UI's "Values to insert" pane can render empty ("Currently no items exist") even though runtime persists data correctly. If the user reports the Insert node "looks broken" or "has no fields," tell them: it's a UI display issue, press the reload (refresh) button on the columns parameter, and it repopulates the schema and the mappings render. No data loss, safe to do anytime.
Common patterns
Dedup by external ID
Default to the Remove Duplicates node ("items seen in previous executions" mode) for plain "have I seen this value?" dedup. It's a one-node solution with an internal store, no schema to maintain. Data Tables only earn the slot when there's a reason for the dedup state to live in a real table:
- You'll query or inspect the dedup state. Dashboards, audit, "what have we processed in the last week?"
- Row-level logic on hits. Per-category TTL ("expire after 30 days for category A, 7 days for category B"), conditional re-process based on stored state, branching on a status column.
- Per-tenant or per-user namespacing that the
Remove Duplicateshistory-store can't express.
When that bar is met:
[Source: { arxivId, ... }]
↓
[Data Table Get: filter arxivId eq $json.arxivId, limit 1]
↓
[IF: result has items?]
├── Yes → [Skip, or apply row-level logic from the stored row]
└── No → [Process] → [Data Table Insert: { arxivId, ...rest }]
For the full pattern surface (upsert, rowNotExists, Get+IF, idempotency keys), see references/DEDUP_PATTERNS.md.
Lookup tables
Stable reference data (country → tax rate, plan → feature flags). Edited via n8n UI, and workflows read at execution:
[Data Table Get: filter country eq $json.country, limit 1]
↓
[Use the looked-up row's taxRate, etc.]
Recent events / audit trail
Append-only insert, queried later:
[Workflow event] → [Data Table Insert: { userId, eventType, payloadSummary }]
createdAt makes "recent events in the last hour" trivial without your own timestamp.
Reference files
| File | Read when |
|---|---|
references/SCHEMA_DESIGN.md |
Designing columns/types, the no-FK relational pattern, mapping mode (defineBelow vs autoMapInputData), when Data Tables are the wrong tool |
references/OPERATIONS.md |
Operation surface (insert/upsert/update/get/delete/rowExists), filter syntax, matchType, orderBy |
references/DEDUP_PATTERNS.md |
Idempotency keys, RemoveDuplicates node vs Data Table dedup, search-then-insert vs upsert |
For expression discipline ($json vs $('Node Name').item.json, the Set-node antipattern), see n8n-expressions-official. For Merge convergence and same-shape branches, see n8n-node-configuration-official references/MERGE_NODE.md.
Anti-patterns
| Anti-pattern | What goes wrong | Fix |
|---|---|---|
| Set node upstream of Insert "to shape the input" | Extra node for nothing, classic Set antipattern, field shape drifts when you add columns | Map directly in the Insert node's per-column slots, OR rename upstream fields to enable auto-map |
Declaring id, createdAt, updatedAt in create_data_table |
Errors, or shadows the system column with a user column that doesn't auto-update | Don't declare them, they're already there |
| Storing application-critical data in Data Tables | If n8n breaks, you lose access | Use a real DB for data you can't lose |
| Cross-app system-of-record in Data Tables | Hard to share with non-n8n consumers, awkward query surface | Use a real DB |
Treating auto-id as a stable cross-instance identifier |
Resets if the table is recreated, not portable | Use a domain ID column (arxivId, requestId) for cross-system references |
| Foreign-key cascade assumptions | n8n doesn't cascade, deleted parents leave orphan children | Soft-delete, or run cleanup workflows that maintain referential integrity |
| Referencing an immediately-prior node when an intermediate stripped json | Insert silently writes NULLs for fields that "should be there" | Reference a stable upstream node by name, or use a NoOp/Merge convergence anchor (see n8n-expressions-official and n8n-node-configuration-official references/MERGE_NODE.md) |
| Manual-map mode + Set node to fix "Currently no items exist" | Doesn't fix anything, that's a UI quirk, you've added a useless Set node | Verify via get_workflow_details that columns.value has your mappings, runtime is fine. Tell the user to press the reload button on the columns parameter to make the UI render the fields. |
Verification before publishing
After creating or updating a workflow that uses Data Tables:
validate_workflowpasses.get_workflow_detailsand inspect each Data Table node'scolumns. Bothvalueand (for manual map)schemapopulated.test_workflowwith pinned data. Insert response should includeid,createdAt,updatedAt.- Inspect actual Data Table contents via UI or follow-up Get to confirm columns aren't silently NULL.
Step 4 especially the first time you wire a new Insert. Context-stripping intermediates + manual map + UI quirk silently produce NULL columns.
Open this reference as its own page
Dedup patterns
"Have we processed this before?" is one of the most common workflow needs, and most of the time the answer doesn't need a Data Table. The Remove Duplicates node has a built-in mode for it: a one-node solution with an internal store. Data Tables earn the slot only when the dedup state needs to do more than answer "seen / not seen."
Default: Remove Duplicates node
For plain "seen this exact value before?" with no associated data:
{
type: 'n8n-nodes-base.removeDuplicates',
parameters: {
operation: 'removeItemsSeenInPreviousExecutions',
dedupeValue: '={{ $json.entryId }}',
options: {
historySize: 10000,
},
},
}
Fits when:
- Dedup is JUST about the value, no metadata to attach.
- History size limit (~10k default) is enough.
- You don't need to inspect or query "what have we seen?"
When Data Tables earn the slot
Reach for a Data Table when you need any of:
- Queryable dedup state. Dashboards, audit, "what have we processed in the last week?"
- Row-level logic on hits. Per-category TTL ("expire after 30 days for category A, 7 days for B"), conditional re-process based on stored state, branching on a status column.
- Per-tenant / per-user namespacing beyond what the history-store can express.
- TTL with cleanup. Daily cleanup of stale markers.
- Volume past ~10k history items.
When that bar is met, pick one of three Data-Table patterns by the branch behavior you want.
Pattern 1: upsert (cleanest)
For "first time → insert, subsequent → update" with no branching:
[Source: { arxivId, ... }]
↓
[Data Table Upsert: matchType allConditions, filter arxivId eq <id>, columns ...]
↓
[Continue with the inserted/updated row's id]
Upsert returns id, createdAt, updatedAt whether insert or update, so downstream doesn't need to know which.
When wrong:
- You need to skip work on duplicates. Upsert always touches the row, wastes compute. Use Pattern 2.
- You need a "first time only" side effect. Upsert can't distinguish without an extra
getto compare timestamps.
Pattern 2: rowNotExists + Insert (skip duplicates)
To skip processing for existing rows:
[Source: { arxivId, ... }]
↓
[Data Table rowNotExists: filter arxivId eq <id>]
↓ (only new items pass through)
[Process: download, summarize, etc.]
↓
[Data Table Insert: { arxivId, ... }]
rowNotExists filters input, and existing rows drop silently.
When wrong:
- You also need to handle existing items (return cached result). Use Pattern 3.
Pattern 3: Get + IF (full control)
For both branches, "process new" AND "return existing":
[Source: { arxivId, ... }]
↓
[Data Table Get: filter arxivId eq <id>, limit 1, alwaysOutputData=true]
↓
[IF: $json.id exists?]
├── Yes (already processed) → [Return existing row's data]
└── No (new) → [Process] → [Data Table Insert] → [Return new row's data]
Two notes:
alwaysOutputData: trueon Get. Without it, no-match produces zero items and the pipeline silently does nothing. With it, Get always emits one item (possibly empty), and the IF can branch.- Both branches must produce the same JSON shape. Otherwise downstream
$json.xbreaks depending on which branch fired. Seen8n-node-configuration-officialreferences/MERGE_NODE.mdfor the Merge convergence anchor.
Pattern decision tree
Need to dedup?
├── Plain "seen this value?" with no metadata, no TTL, fits in ~10k history?
│ └── Default: Remove Duplicates node, no Data Table
│
└── Need queryable state, row-level logic, TTL, or per-tenant namespacing?
├── Want "skip duplicates" (no work on existing)? → Pattern 2: rowNotExists + Insert
├── Want "first-time insert, subsequent update"? → Pattern 1: upsert
└── Want both branches (process new, return cached)? → Pattern 3: Get + IF + same-shape branches
Idempotency keys
For webhook workflows safe under retries:
[Webhook receives X-Request-Id header]
↓
[Data Table Get: filter requestId eq <id>, limit 1, alwaysOutputData=true]
↓
[IF: row exists?]
├── Yes → [Respond with cached response stored on the row]
└── No → [Process]
↓
[Data Table Insert: { requestId, responseBody, ... }]
↓
[Respond with the response]
Two design choices:
- Store response or just marker? Storing lets you serve the same answer on retry (full idempotency). Marker-only suffices when clients retry only to confirm receipt.
- TTL? Markers shouldn't live forever. Run a daily cleanup deleting rows where
createdAt < now - <retry window>.
Volume notes
- Data Tables handle tens of thousands of rows. Past that, dedup queries get slow.
- For millions of keys, use a real cache (Redis, DynamoDB).
- For hundreds of rows with no metadata, the
Remove Duplicatesdefault is simplest.
Cross-references
- Filter syntax:
OPERATIONS.md. - Where dedup fits in API workflows:
n8n-error-handling-officialreferences/API_WORKFLOWS.md. alwaysOutputData: truerule:n8n-node-configuration-officialand the SDK reference's "Handle empty outputs."
Open this reference as its own page
Data Table operations
The dataTable node has two resources: row and table. Most work is row. This covers row operations and the filter/sort surface.
Row operations
insert
Always-add. Creates a row, and n8n assigns id, createdAt, updatedAt.
Required: dataTableId, columns.
Returns: { id, createdAt, updatedAt }.
Use when: row is known new (post-dedup, append-only).
upsert
Update matching rows, insert if none match.
Required: dataTableId, matchType, filters.conditions, columns.
Use when: you have a domain identifier and want first-time and subsequent-time handled the same.
{
operation: 'upsert',
dataTableId: { __rl: true, value: '<table-id>', mode: 'list' }, // real ID from search_data_tables (or explore_node_resources tableSearch)
matchType: 'allConditions',
filters: {
conditions: [
{ keyName: 'arxivId', condition: 'eq', keyValue: '={{ $("Source").item.json.arxivId }}' },
],
},
columns: {
mappingMode: 'defineBelow',
value: {
arxivId: '={{ $("Source").item.json.arxivId }}',
title: '={{ $("Source").item.json.title }}',
// ... other columns
},
},
}
update
Modify matching rows, no-op if none match (unlike upsert).
Required: dataTableId, matchType, filters.conditions, columns.
Use when: the row should exist, and you're modifying state.
get
Fetch rows matching a filter. Returns 0+ rows.
Optional: returnAll (vs limit), orderBy + orderByColumn + orderByDirection.
{
operation: 'get',
dataTableId: { __rl: true, value: '<table-id>', mode: 'list' }, // real ID from search_data_tables (or explore_node_resources tableSearch)
matchType: 'anyCondition',
filters: {
conditions: [
{ keyName: 'arxivId', condition: 'eq', keyValue: '={{ $json.arxivId }}' },
],
},
returnAll: false,
limit: 1,
}
One item per row out. Empty filter = empty output (downstream may need alwaysOutputData: true to fire).
deleteRows
Remove matching rows. Same filter shape. Returns deleted count (or per-row depending on version).
Use carefully. No cascade, so child rows referencing this id become orphans.
rowExists / rowNotExists
Filter input into "has a matching row" vs "doesn't." Output is input items, filtered.
Use when: dedup logic is "skip already-in-table" (or vice versa) and you want one node instead of Get + IF.
{
operation: 'rowNotExists',
dataTableId: { __rl: true, value: '<table-id>', mode: 'list' }, // real ID from search_data_tables (or explore_node_resources tableSearch)
matchType: 'allConditions',
filters: {
conditions: [
{ keyName: 'arxivId', condition: 'eq', keyValue: '={{ $json.arxivId }}' },
],
},
}
Non-matches pass through, matches drop. Followed by Insert, this is dedup-as-a-pipeline.
Filter syntax
filters.conditions applies to get, update, upsert, deleteRows, rowExists, rowNotExists.
Each condition:
{
keyName: 'columnName', // or expression
condition: 'eq', // operator
keyValue: '={{ $json.value }}', // or literal
}
Operators:
| Operator | Meaning |
|---|---|
eq |
equals |
neq |
not equals |
gt / gte |
greater than / greater-or-equal |
lt / lte |
less than / less-or-equal |
like |
string match |
notLike |
string mismatch |
isEmpty / isNotEmpty |
null/empty checks (no keyValue needed) |
isTrue / isFalse |
boolean checks (no keyValue needed) |
matchType: AND vs OR
'allConditions': AND.'anyCondition': OR.
Default in some versions is anyCondition, surprising for multi-column filters. For AND, set matchType: 'allConditions' explicitly.
Sorting (get only)
{
operation: 'get',
// ...
orderBy: true,
orderByColumn: 'createdAt',
orderByDirection: 'DESC',
}
Sort by any column (including system-managed). id ordering is insertion order. createdAt matches normally but can differ after table repair.
Pagination
There's no native offset parameter on get. limit is per-call, so larger results need one of:
returnAll: true(memory caution on large tables).returnAll: false+limit+ repeated calls with a keyset filter (e.g.,id > <last seen>). Keyset, not offset, because there's no offset to set.
For "process new since last sync," filter on createdAt > <last sync> + orderBy createdAt ASC, capture the new max, save for next sync.
Common pitfalls
Missing matchType on multi-column filters
Defaults to OR in some versions. For AND, set matchType: 'allConditions'.
Filtering on a non-existent column
May error or silently match nothing depending on version. keyName/orderByColumn are @loadOptionsMethod columns: resolve real names via explore_node_resources (getDataTableColumns, loadOptions) rather than guessing spelling.
Update with no match silently does nothing
No error. Follow with a get to confirm, or use upsert for create-or-update.
Insert without dedup re-inserts on every run
Trigger retries (webhook retry, scheduled re-run) create duplicates. Use upsert, rowNotExists + Insert, or upstream dedup. See DEDUP_PATTERNS.md.
returnAll: false with no limit
Defaults to limit: 50 in many versions. Set returnAll: true or bump limit if downstream expects more.
Cross-references
- Idempotency / dedup:
DEDUP_PATTERNS.md. - Schema design and mapping mode:
SCHEMA_DESIGN.md. $json.xvs$('Source').item.json.x:n8n-expressions-official.
Open this reference as its own page
Data Table schema design
Day-one schema decisions stick for the table's life. Data Tables are forgiving (add columns later) but constrained (no foreign keys, modest scale, n8n-internal, no in-place column type changes). Once a column is string, it stays string until you create a new column and migrate. Pick types deliberately on day one.
The system-managed columns
id bigserial primary key, auto-assigned, can't write to
createdAt timestamp set on insert
updatedAt timestamp refreshed on each update
Don't declare these in create_data_table. Build your schema as if they exist, because they do.
Picking column types
Primitives only:
| Type | When |
|---|---|
string |
Text, IDs, enums, anything non-numeric/non-boolean |
number |
Counters, prices, scores, anything you'll do math on |
boolean |
True/false flags. Don't overload string with 'yes'/'no'. |
date |
Timestamps you set explicitly (distinct from auto createdAt/updatedAt) |
No JSON / object / array column types. Only the four primitives above.
The _object convention for nested data
When you need to store an object or array (e.g., the keyInsights array from an LLM, a parsed JSON response), use a string column and stringify on write. Mark the column with an _object postfix so future readers (humans and agents) know to parse it:
// On insert:
columns: {
value: {
arxivId: '={{ $json.arxivId }}',
keyInsights_object: '={{ JSON.stringify($("Summarize").item.json.output.keyInsights) }}',
topics_object: '={{ JSON.stringify($("Summarize").item.json.output.topics) }}',
},
}
// On read:
{{ JSON.parse($("Get Paper").item.json.keyInsights_object) }}
The _object postfix is the contract: any column ending in _object holds a JSON-stringified value and must be JSON.parse(...)'d on read. Workflows reading the table know what to do without inspecting the data.
Storage format ≠ interface format
The most important rule about _object columns: stringify-on-write, parse-on-read, and never let the stringified shape leak past the storage boundary. The string is the storage format, not the interface format.
What this means in practice:
- Inside the sub-workflow that owns the table, you stringify just before the Data Table Insert/Update. That's the storage-format boundary going in.
- Inside the sub-workflow that owns the table, you parse just after the Data Table Get. That's the storage-format boundary coming out.
- When the sub-workflow returns data to a caller, return arrays as arrays and objects as objects (the natural shape) even if those values came from
_objectcolumns. Do not return strings that the caller has to parse.
Why: the caller doesn't (and shouldn't) know that you store things as stringified strings. That's an internal implementation detail of the table-owning workflow. Forcing every caller to remember to JSON.parse is the same kind of API leak as exposing your DB schema directly to consumers.
The failure mode
Any sub-workflow that owns a Data Table with _object columns tends to develop two return paths: a "fresh" path (the data was just produced, still in natural shape) and a "cached" path (read back from the table, where _object fields are stringified). The wrong instinct: stringify the fresh path's output to "match" the cached shape. The right instinct: parse the cached path's output, so both paths return arrays as arrays and objects as objects.
Symptom of the wrong choice: every caller has to JSON.parse(...) the return values. Templates choke, downstream tools see strings where they expect arrays, and the whole system has a hidden coupling to your storage representation.
Fix: in the sub-workflow's final return node, parse any _object field back to its natural shape:
// Final return node (Set / Edit Fields):
{
id: '={{ $("Merge").item.json.id }}',
name: '={{ $("Merge").item.json.name }}',
items: '={{ JSON.parse($("Merge").item.json.items_object) }}',
metadata: '={{ JSON.parse($("Merge").item.json.metadata_object) }}',
}
The return contract is: arrays as arrays, objects as objects. Storage representation stays inside the table-owning workflow.
When NOT to use _object columns
- You need to query the nested data (filter
WHERE topics CONTAINS 'AI'). String columns can't be queried structurally, so you'd be doing client-side filtering after agetof everything. For queryable nested data, denormalize into a child table with relational design (see "Designing relationally without foreign keys" below) or use a real DB. - The nested data is huge (large arrays, deep trees, multi-MB objects). Data Tables can hold it, but performance and the n8n DB size both suffer. Use external storage and reference by URL.
Naming
- camelCase columns:
arxivId,publishedAt,isProcessed. Matches the auto-managed columns (createdAt,updatedAt), so a query reading both reads as one consistent table. - Title Case with spaces tables:
Papers,Recent Events,Customer Dedup. Tables are user-facing in the n8n UI (picker dropdowns, table list), so they read like proper nouns. Plural for sets, singular for one-row-per-global-thing (rare). - Domain prefixes for relational columns:
paperId,customerId,episodeId. Makes relationships obvious without FK enforcement. _objectpostfix is a marker, not casing. Stringified-blob columns keep the underscore:keyInsights_object,topics_object. The underscore signals "parse this on read" the same way_v2or_legacywould, so it stays even when the rest of the name is camelCase.
Designing relationally without foreign keys
Data Tables don't enforce referential integrity, and they don't run multi-row transactions. You're responsible for both: integrity via workflow logic, atomicity via error handling.
No transactions, plan for partial failure
If you Insert a parent then Insert a child and the child fails, the parent row is already written. There is no rollback. Any relational sequence that spans more than one write (parent + child Inserts, cascade-delete, multi-table updates) needs error handling, full stop. Pick one:
- Compensating writes. Catch the failure mid-sequence and undo what already succeeded (delete the parent if the child Insert errors).
- Idempotent retry. Design the sequence so re-running it is safe, usually with
upsertand stable domain IDs, so a partial first run completes correctly on retry. - Soft state markers. Add a
statuscolumn to the parent (pending,complete), flip tocompleteonly after all child writes land, and consumers ignorepending.
See n8n-error-handling-official for the error-output wiring.
Reference rows by id
Child holds parent's id:
Papers Papers.id is the key
id (auto)
arxivId (string)
title (string)
...
Paper Summaries paperId references Papers.id
id (auto)
paperId (number)
summaryText (string)
generatedAt (date)
When inserting a child, capture the parent's id from a prior get (or the insert response):
// After an insert into Papers, the response has { id, createdAt, updatedAt }.
// Use that id directly:
{
operation: 'insert',
dataTableId: { ..., value: '<Paper Summaries table id>' },
columns: {
mappingMode: 'defineBelow',
value: {
paperId: '={{ $('Insert Paper').item.json.id }}',
summaryText: '={{ $('Summarize').item.json.output.tldr }}',
generatedAt: '={{ $now.toISO() }}',
},
},
}
Enforce integrity in the workflow
Before inserting a child, look up the parent. Before deleting a parent, decide:
- Cascade-delete children: a separate Data Table Delete on children, filtered by parent
id. - Soft-delete parent: add an
archivedboolean, and children filter onarchived = false. - Orphan children: leave them. Useful when the relationship is loose.
Pick one per relationship. Mixed strategies cause silent bugs.
Watch for "child without parent"
Delete a parent and forget children, and they point at a non-existent id. n8n won't tell you. Symptoms surface later when joins return nothing.
Guards:
- Don't delete parents without a child cleanup.
- Periodic audit workflow: scheduled scan for child rows whose parent FK doesn't exist.
- Soft-delete by default: deletion becomes
archived=true, and children stay valid.
When Data Tables are the wrong tool
Reach for an external DB when:
- Data is shared across apps. Other systems read or write it, and n8n is one of many.
- Volume is high. Millions of rows, write-heavy.
- You need ACID across tables. Data Table operations are per-row.
- You need foreign-key enforcement. Data Tables won't enforce.
- You need backup/restore independent of n8n. Data Tables live in n8n's DB.
When Data Tables ARE the right tool:
- Workflow-local persistent state (dedup keys, idempotency markers, recent events for an in-n8n dashboard).
- Lookup tables that change rarely (country → tax rate, plan → feature flags).
- Per-session inventories (e.g., files uploaded in a conversation, keyed on
sessionId). - Counters / aggregates with bounded volume.
Schema evolution
- Add column:
add_data_table_columnor UI. Existing rows get NULL, so backfill if needed. - Rename:
rename_data_table_column. Update workflows referencing the old name. - Drop:
delete_data_table_column. Permanent. Ensure no workflow still reads it. - Type change: not in-place. Add new column, copy via workflow, drop old, rename new. Pre-design types to avoid.
A healthy table
- 3 to 12 columns. Past that, consider splitting.
- Names obvious to a reader who hasn't seen the writing workflow.
- Every column referenced by at least one workflow. Audit periodically.
- Domain identifiers (
arxivId,customerId) alongside auto-idwhen needed.
Mapping mode on Insert/Update/Upsert
The columns parameter has two modes: mappingMode: 'defineBelow' (manual per-column expressions) and mappingMode: 'autoMapInputData' (n8n maps by upstream field name).
Default to defineBelow. Explicit, expressions sit at the consumer, refactors read clearly. Auto-map only when you have a stable 1:1 between upstream field names and column names. Drift in either side silently breaks the mapping.
For the $json.x vs $('Node Name').item.json.x discipline that prevents silent NULLs when intermediate nodes strip json, see n8n-expressions-official. For Merge convergence and same-shape branches, see n8n-node-configuration-official references/MERGE_NODE.md.
Cross-references
- Querying / filtering:
OPERATIONS.md. - Dedup patterns:
DEDUP_PATTERNS.md. - Data Tables vs external storage: parent
SKILL.md. - Expression discipline (
$jsonvs named references, Set-node antipattern):n8n-expressions-official. - Branch / Merge wiring:
n8n-node-configuration-officialreferences/MERGE_NODE.md.
More in this playbook
Safe to turn on
Use this skill when an agent or person is about to create, change or enable an automation inside someone else's account or a shared environment: "create this workflow", "build it in the customer's account", "turn it on", "go live", "deploy this automation". Produces a proposal the human approves, an automation created in the off state, and a short list of what only the human can finish.
Workflow buildingMITn8n agents
Design n8n AI agents the right way. Use when building or editing any @n8n/n8n-nodes-langchain.* AI node — an AI Agent, LLM chain, Text Classifier, or Information Extractor — and whenever the user mentions AI agents, LLM with tools, tool calling, $fromAI, system prompts, agent memory, sessionId, structured/JSON output, output parser, RAG, vector store, a chat assistant/bot, or human-in-the-loop review. Covers Agent-vs-chain-vs-classifier choice, the model/memory/tools/outputParser slots, tool names/descriptions as prompt, structured output with autoFix, memory, RAG, human review, and chat topologies.
Workflow buildingMITn8n agents
Design n8n AI agents the right way. Use when building or editing any @n8n/n8n-nodes-langchain.* AI node — an AI Agent, LLM chain, Text Classifier, or Information Extractor — and whenever the user mentions AI agents, LLM with tools, tool calling, $fromAI, system prompts, agent memory, sessionId, structured/JSON output, output parser, RAG, vector store, a chat assistant/bot, or human-in-the-loop review. Covers Agent-vs-chain-vs-classifier choice, the model/memory/tools/outputParser slots, tool names/descriptions as prompt, structured output with autoFix, memory, RAG, human review, and chat topologies.


