3 ms·
Its really common to store json documents inside rows in normal relational databases. This can be because, actually, you have a json blob that is associated wi
by willvarfar 8y ago
Its really common to store json documents inside rows in normal relational databases.
This can be because, actually, you have a json blob that is associated with the row e.g. I have a script that scrapes some public registries of historic monuments (I have dull hobbies!) and it just stores the responses in a json column. Its convenient.
Another way these 'dynamic columns' are used is to flatten one-to-many relationships. For example, I have a database where account managers can add arbitrary tags to customers. The classic approach would be to have a customer table, then a 1:M into a tag table with the key value, and then another M:1 for the key to go from the key id to the key names. Instead, I just have a json column with all the key values in it, right there in the customer record. Its convenient!
- the_duke 8y agoI've done this too. Note that for databases that support array columns, this is much nicer to represent with an array. Postgres supports them, for example. (SQLite doesn't)
- micahlopez 8y agoIs there a link for the support documentation?
- stergios 8y agoColumn arrays have been in postgreSQL since 9.1 at least. https://www.postgresql.org/docs/9.1/arrays.html https://www.postgresql.org/docs/9.1/arrays.html