mongoexport gave you.CREATE TABLE "users" ( id VARCHAR(24) NOT NULL PRIMARY KEY, address JSONB NOT NULL, age DOUBLE PRECISION NOT NULL, email TEXT NOT NULL, lastseen TEXT, orders JSONB NOT NULL, signedupat TIMESTAMPTZ NOT NULL, tags JSONB, teamid VARCHAR(24) NOT NULL );
The table above is the faithful copy: one column per field, nested structures as JSON. That is what a migration writes today.
A faithful copy is not a relational schema. Here is the structure hiding inside these documents — which nested parts deserve their own tables, which flatten into columns, and which really are just JSON.
A consistently-shaped embedded object. Flattening it into prefixed columns makes the fields directly queryable and indexable, with no join.
Repeating subdocuments with a consistent shape. This is a one-to-many relationship: a child table with a foreign key back to the parent is the relational form.
An array of scalars has no internal structure to normalise. Keep it as JSON, or split it into a child table later if you need to query the elements individually.
This analysis is advisory today — a migration still writes the flat table above. Running it against your real collection samples 500 documents instead of the handful you pasted, which is what makes the shape and frequency numbers meaningful. Connect a database →
Run it against your real database
NoSQLSync samples your collections, infers the schema, and migrates the data with live CDC. Free plan, no credit card.
Start free →