Company
Date Published
Author
Bryn Llewellyn
Word count
4964
Language
English
Hacker News points
None

Summary

YugabyteDB has two JSON data types, `json` and `jsonb`, which can be used to store documents in a column in a YSQL table. The `jsonb` data type stores a parsed representation of the document hierarchy of subvalues in an internal format, making it more efficient for operations such as indexing and querying. YugabyteDB supports various JSON operators and functions, including content-based queries, shreds, shred operations, and index support. The database also supports constraints on JSON expressions, allowing developers to enforce business rules on the data stored in JSON documents. An example is provided of a function `chk_book_doc_is_conformant` that checks if a document conforms to certain expected structures, demonstrating how to create a constraint on a PL/pgSQL function that encapsulates rich JSON functionality.