4 ms·
> How do I store it? To me, NoSQL seemed like the choice in the past. If you're using postgres, you could use a column of type jsonb. Postgres comes with many
by pilif 8y ago
> How do I store it? To me, NoSQL seemed like the choice in the past.
If you're using postgres, you could use a column of type jsonb. Postgres comes with many operators and functions (https://www.postgresql.org/docs/11/functions-json.html https://www.postgresql.org/docs/11/functions-json.html) to query into jsonb typed columns and many of them even allow index usage for very quick access.
However, the other option would be to use proper SQL tables and normalization to store your data. Then you can query very easily for your data and by making use of a real typed schema, you get free validation of your input and protection against corrupted data later down the line.
And aggregating your information to produce reports over various documents becomes very easy too.
Here's above schema in SQL DDL, Postgres dialect. I'm not sure about nullability and types of your values, but by making use of database types and constraints, you can describe the shape of your data much better which further helps you preventing invalid data from being stored due to bugs
create table things (
id bigserial primary key,
a text not null
);
create table c_things (
thing_id bigint not null
primary key
references things (id) on delete cascade,
ca text not null,
cd text not null
);
create table d_things(
thing_id bigint not null
primary key
references things (id) on delete cascade
-- ...
)
- philliphaydon 8y agoIn .NET I use Marten to use PostgreSQL as a document database, gives you a typed schema with JSONB storage.
- ako 8y agoOr you can store the jsonb in Postgres and use views to also present it in a normalized way. See example here: https://www.endpoint.com/blog/2016/02/29/converting-json-to-postgresql-values https://www.endpoint.com/blog/2016/02/29/converting-json-to-...