9
JSON in a SQL World By Robert Sell Twitter: @DukeOfNode Linkedin: http://www.linkedin.com/in/robert-sell

JSON as a SQL Datatype

Embed Size (px)

Citation preview

Page 1: JSON as a SQL Datatype

JSON in a SQL WorldBy Robert Sell

Twitter: @DukeOfNodeLinkedin: http://www.linkedin.com/in/robert-sell

Page 2: JSON as a SQL Datatype

Who Am I

• Application Architect & Data Engineer aka The Data Donkey• The guy who creates money from information via our Analytic Product• In another life I ran and managed ecommerce operations and integrated

them into IT Systems• Spent a large amount of time moving data and analyzing it so people can

make good business decisions

Page 3: JSON as a SQL Datatype

Popular Ways to Encode Key Value Information

• Uncomplex Tuples (CSV, TSV) => (Rob, Sell)

• XML (Soap) => <person><firstName>Rob</firstName><lastName>Sell</ lastName ></person>

• JSON (YAML, CSON) => {“person”:{“firstName”: “Rob”, “lastName”: “Sell”}}

Page 4: JSON as a SQL Datatype

Great JSON Properties

• First Class Support for Basic Data Types: Numbers, Strings, Boolean• First Class Support for Collections!• First Class Support for Hierarchical Structures!• Other Stuff: Readable, Not Bloated, Easily Parsible Via

Javascript

Page 5: JSON as a SQL Datatype

NoSQL Advantages

• Easy to get started• Loosely structured so easier to change• Easier to scale out then some SQL databases• Data is in a form closer to how the program thinks of it

Page 6: JSON as a SQL Datatype

Working With Data Causes a War

• Only You Can Prevent Forest Fires !!!• SQL uses set and aggregation operators to manipulate and

aggregate information• JSON and OOP languages uses map and reduce• SQL no longer equals flat data with JSON in it

Page 7: JSON as a SQL Datatype

JSON Comes to SQL

• JSON in Postgres 9.4 and JSONB in 9.5• MySQL in 5.7• T-SQL in 2016

Page 8: JSON as a SQL Datatype

Why Use JSON in SQL

• SQL is all ready your primary system for storing and transmitting data• It’s painful to make temporary classes for storage (statically typed

languages)• Decent performance with very little transformation necessary• Databases normally apply logic to information so apply logic to JSON

instead of in an application• You don’t want to lose information

Page 9: JSON as a SQL Datatype

Use Cases

• Data Warehousing• Need to Backup data from external platform and use it later• Don’t want to pay for ETL applications to move data to SQL

databases (Zendesk, Shopify, etc)