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.
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...
- Download the the white paper: Using NoSQL Features in Postgres
- See for yourself how Postgres performs with unstructured data against MongoDB
- Sign up for upcoming NoSQL for the Enterprise webcasts