This document discusses Marten, an ORM for .NET that allows for document-oriented data access to PostgreSQL. It begins with an overview of microservices and document databases, then discusses PostgreSQL's support for JSON and JSONB data types. It introduces Marten and demonstrates its basic features for querying and updating JSONB documents in PostgreSQL from .NET code. The presentation also covers more advanced Marten capabilities like indexing, profiling, and tenancy support, with examples.
7. Marten as Document DB for .NET applications Киев 2017
SQL:2016, ISO/IEC TR 19075-
6:2017: SQL support for JavaScript
Object Notation (JSON)
• December 2016
• Standard uses strings to store JSON data, standard
defines functions that interpret strings as JSON data
• <expr> is [not] json
• json_object([key] <expr> value <expression> [,…])
• json_array([<expr>[,…]]) , json_array(<query>)
• json_arrayagg(<expr> [order by …])
• json_objectagg([key] <expr> value <expression>)
• json_exists(<json>, <path>)
• json_value(<json>, <path> [returning <type>])
• json_query(<json>, <path> …)
• json_table(<json>, <path> columns …)
• JSON Path
8. Marten as Document DB for .NET applications Киев 2017
PostgreSQL JSON(B) Operators
• -> Get JSON object field by key
• ->> Get JSON object field as text
• #> Get JSON object at specified path
• #>> Get JSON object at specified path as text
• @> Does the left JSON value contains the right
JSON
9. Marten as Document DB for .NET applications Киев 2017
PostgreSQL vs MongoDB
Local Data(Structured Data)
* Data model explicitly determines the structure of data
* Schema is fixed
* Easy to visualize
* A lot of Math
* Ready-made query language, SQL
Shared data(Semi-structured Data)
* Self-describing structure
* The schema can easily be changed
* Helps to not worry about object-relational impedance mismatch
* Support for nested or hierarchical data
* Support for lists of objects
* Can represent the information of some data sources that cannot be constrained by schema
* Flexible format for data exchange between different types of databases
Overview and choose of document db
* Why not xml, json in SQL/Oracle - speed
* Why not RavenDB – not usable
* Why not Mongo – too complicated in configuration
Standard for JSON in RDMS from ISO
Only Oracle and partially SQL Server support parts of standart