From the course: Advanced SQL for Data Scientists

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Hstore for key-value pairs

Hstore for key-value pairs

From the course: Advanced SQL for Data Scientists

Start my 1-month free trial

Hstore for key-value pairs

- [Instructor] Now, Postgres has features that may be more properly considered in the realm of NoSQL, including key-value stores and support for document structures using JSON. So let's first take a look at hstore. hstore is a data type for storing sets of key-value pairs. Now, we use hstore by first creating an extension. And an extension is a package or module that's part of Postgres but not installed by default. So we essentially install it by using the CREATE EXTENSION hstore command, and then we can create cables as we would normally. And for one of the comp source, several of the comps, we could specify the data type as hstore. Then when we insert data, we basically insert a string which is a list of key-value pairs. Now, why would you use hstore? Well, it's useful when it helps when keys are not predefined. So that is, the keys in the list can change arbitrarily. So if you have a large number of attributes and many…

Contents