Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Unpivoting data using JSON functions

Most of our use-cases for the built-in Json support in PostgreSQL is not to implement schemaless design storage, but instead to remold data. Remolding can take the form of restructuring data into json documents suitable for web maps, javascript charting web apps, or datagrids. It also has uses beyond just outputting data in json form. In addition the functions are useful for unraveling json data into a more meaningful relational form.

One of the common cases we use Json Support is what we call UNPIVOTING data. We demonstrated this in Postgres Vision 2018 presentation in slide 23. This trick won't work in other relational databases that support JSON because it also uses a long existing feature of PostgreSQL to be able to treat a row as a data field.

Continue reading "Unpivoting data using JSON functions"


This post first appeared on Postgres OnLine Journal, please read the originial post: here

Share the post

Unpivoting data using JSON functions

×

Subscribe to Postgres Online Journal

Get updates delivered right to your inbox!

Thank you for your subscription

×