NoSQL Code Samples

NoSQL Code Samples

Postgres Supports Structured and Unstructured Data

NoSQL technologies, such as document stores and key-value stores, support incremental development methodologies where data models emerge as the application goes through cycles of agile development, instead of being carefully crafted upfront using ER-diagramming, normal form analysis, and conceptual/logical/physical design frameworks.

NoSQL and ACID Together

Postgres has introduced JSON (2012) and HSTORE (2006) to provide solution architects and developers a schema-less data management option that is fully integrated with Postgres’ robust ACID (Atomic, Consistent, Isolation and Durable) model.

 

JSON Datatype Support

Postgres offers robust support for inserting JSON data complete with a validating parser, storage, and a wide variety of functions for extracting elements from within JSON documents.

 

JSON In and JSON Out

Postgres also offers the ability to easily encode query result sets into JSON which means application developers that prefer to work natively with JSON can easily obtain their data from Postgres in its original format.

 

Document and Key-Value Data

Postgres has also offered HSTORE for key-value support since 2006 but unlike other NoSQL-only solutions, a key-value store created in Postgres is ACID compliant. Just like JSON, HSTORE can be used to emulate a schema-less database when that is desirable. There are also functions that convert Postgres-maintained key-value data to JSON formatted data, which increases the flexibility and scope of NoSQL-like applications that can be addressed by Postgres.

 

JSON and Javascript

Postgres provides Javascript capabilities right in the database, allowing web developers to write centralized database logic using the same JavaScript engine that powers their web clients. Developed by Google for Chrome, V8 is designed to work on the client and the server and is also at the heart of Node.js. V8 is available as the Postgres add-on PL/V8.  With Postgres, your developers can work with their web data format and web application language in the database too.

 

Postgres for When Precision Counts

Postgres 9.4 adds JSONB, a second JSON type with a binary storage format that is significantly different than BSON, which is used by one of the larger document-only database providers. BSON stands for Binary JSON, but in fact not all JSON values can be represented using BSON. For example, BSON cannot represent an integer or floating-point number with more than 64 bits of precision, whereas JSONB can represent any arbitrary JSON values.

For more information about the JSON capabilities in Postgres...