SlideShare a Scribd company logo
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
MySQL Document Store dirigido a
Desarrolladores
Keith Hollman
MySQL Principal Solution Architect
keith.hollman@oracle.com
DEMO
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
Safe Harbor Statement
The following is intended to outline our general product direction. It is intended for
information purposes only, and may not be incorporated into any contract. It is not a
commitment to deliver any material, code, or functionality, and should not be relied upon
in making purchasing decisions. The development, release, and timing of any features or
functionality described for Oracle’s products remains at the sole discretion of Oracle.
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
Install MySQL 8.0
$ export PATH=$PATH:/usr/local/mysql/mysql-shell-commercial-8.0.11-linux-
glibc2.12-x86-64bit/bin:/usr/local/mysql/mysql-commercial-8.0.11-linux-
glibc2.12-x86_64/bin
$ cd /usr/local/mysql/mysql-commercial-8.0.11-linux-glibc2.12-x86_64/bin
$ mysqld --defaults-file=my.cnf --initialize-insecure
$ mysqld --defaults-file=my.cnf &
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
Download & install Mongo
$ tar zxvf mongodb-linux-x86_64-4.0.0.tar.gz
$ cd /usr/local/mongodb-linux-x86_64-4.0.0
$ export PATH=$PATH:/usr/local/mongodb-linux-x86_64-4.0.0/bin
$ mkdir -p /opt/mongo/data mongo/log
$ vi mongod.conf
systemLog:
destination: file
path: "/opt/mongo/log/mongod.log"
logAppend: true
storage:
dbPath: "/opt/mongo/data"
...
$ mongod --config /usr/local/mongodb-linux-x86_64-4.0.0/mongod.conf
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
Download data to import into mongo
• https://docs.mongodb.com/manual/tutorial/geospatial-tutorial/index.html
• File to be downloaded is:
– https://raw.githubusercontent.com/mongodb/docs-
assets/geospatial/restaurants.json
$ mongoimport DocStore/demo/restaurants.json -c restaurants
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
Export data for importing into MySQL
• This example is inspired by @datacharmer's work:
https://www.slideshare.net/datacharmer/mysql-documentstore
• And also:
https://www.slideshare.net/lefred.descamps/mysql-document-store-how-to-replace-a-
nosql-database-by-mysql-without-effort-but-with-a-lot-gains
$ mongo --quiet --eval 'DBQuery.shellBatchSize=30000; 
db.restaurants.find().shellPrint()' 
| perl -pe 's/(?:ObjectId|ISODate)(("[^"]+"))/ $1/g' 
> DocStore/demo/all_recs.json
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
• Before we start loading data, let's
tail the general_log:
$ cd /opt/mysql/8011/data
$ tail -100f tail -100f
khollman_8011.log
• Create the environment within
MySQL:
$ cd DocStore/demo
$ mysqlsh --uri root@localhost
session.createSchema('test')
use test
db.createCollection('restaurants')
py
import json
import re
with open ('all_recs.json', 'r') as
json_data:
for line in json_data:
skip = re.match('Type', line)
if not skip:
rec = json.loads(line)
db.restaurants.add(rec).execute()
Loading data into MySQL
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
• Now the data is imported, let's
query it:
db.restaurants.find()
db.restaurants.find().limit(1)
db.restaurants.find().fields(["_id","na
me","cuisine"]).limit(2)
• Using sql still? For whatever reason:
session.sql("show create table
restaurants")
session.sql("select * from
restaurants")
session.sql("select * from restaurants
limit 2")
• Let's update an attribute of the
collection, using the id:
db.restaurants.modify("_id='55cba2476c
522cafdb053add'").set("cuisine","Itali
an")
db.restaurants.find("_id='55cba2476c52
2cafdb053add'")
Querying data
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
Querying data (cont.)
• We're ACID, and can still do transactions:
session.startTransaction()
db.restaurants.remove("_id='55cba2476c522cafdb053add'")
db.restaurants.find("_id='55cba2476c522cafdb053add'")
db.restaurants.modify("_id ='55cba2476c522cafdb053ade'").set("name", "The
Hybrid Lunch")
db.restaurants.find("_id = '55cba2476c522cafdb053ade'")
session.rollback()
db.restaurants.find("_id='55cba2476c522cafdb053add'")
db.restaurants.find("_id = '55cba2476c522cafdb053ade'")
• Using SQL and formatting:
SELECT doc->>"$.name" AS name, doc->>"$.cuisine" AS cuisine FROM restaurants
where doc->>"$.cuisine" is not null;
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
• Getting data out of the Collection,
dynamically:
ALTER TABLE restaurants ADD COLUMN
borough VARCHAR(20) GENERATED ALWAYS
AS
(json_unquote(json_extract(`doc`,'$.bo
rough'))) VIRTUAL;
• same as:
ALTER TABLE restaurants ADD COLUMN
borough VARCHAR(20) GENERATED ALWAYS
AS
(doc->>"$.borough") VIRTUAL;
• Using MySQL 8.0 CTE:
WITH cte1 AS (SELECT doc->>"$.name" AS
name, doc->>"$.cuisine" AS cuisine,
(SELECT AVG(score) FROM
json_table(doc, "$.grades[*]" COLUMNS
(score INT PATH"$.score")) AS r) AS
avg_score FROM restaurants) SELECT
*, RANK() OVER (PARTITION BY cuisine
ORDER BY avg_score) AS `rank`
FROM cte1 ORDER BY `rank`, avg_score
DESC LIMIT 30;
Querying data (cont.)
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
More examples & Information
• https://elephantdolphin.blogspot.com/2018/06/mongodb-versus-mysql-
document-store.html
• https://mysqlserverteam.com/mysql-8-0-from-sql-tables-to-json-
documents-and-back-again/
• https://www.mysql.com/news-and-events/web-seminars/nosql-
development-for-mysql-document-store-using-java/
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
Preguntas?
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
MySQL NoSQL JSON JS Python "Document Store" demo

More Related Content

What's hot (20)

PPTX
MySQL in oracle_environments(Part 2): MySQL Enterprise Monitor & Oracle Enter...
OracleMySQL
 
PPTX
Simple Way for MySQL to NoSQL
Okcan Yasin Saygılı
 
PDF
The MySQL SYS Schema
Mark Leith
 
PDF
MySQL Technology Overview
Keith Hollman
 
PPT
MySQL in Oracle environment : Quick start guide for Oracle DBA (Part 1)
OracleMySQL
 
PDF
Introduction to Apache Hive
Avkash Chauhan
 
ODP
Introduction to MySQL Enterprise Monitor
Mark Leith
 
PPT
How to integrate Splunk with any data solution
Julian Hyde
 
PPTX
Ingesting streaming data for analysis in apache ignite (stream sets theme)
Tom Diederich
 
PPTX
DataStax | Deploy DataStax Enterprise Clusters with OpsCenter (LCM) (Manikand...
DataStax
 
ODP
MySQL Monitoring Mechanisms
Mark Leith
 
PDF
MySQL Server Defaults
Morgan Tocker
 
PDF
Mysql tech day_paris_ps_and_sys
Mark Leith
 
PPTX
Quick MySQL performance check
Tom Diederich
 
PPSX
implementation of a big data architecture for real-time analytics with data s...
Joseph Arriola
 
PDF
How to Find Patterns in Your Data with SQL
Chris Saxon
 
PDF
MySQL Enterprise Edition - Complete Guide (2019)
Keith Hollman
 
PDF
Upgrade your javascript to drupal 8
Théodore Biadala
 
PDF
Query Optimization with MySQL 5.7 and MariaDB 10: Even newer tricks
Jaime Crespo
 
PPTX
Protecting your data from SQL Injection attacks
Kevin Alcock
 
MySQL in oracle_environments(Part 2): MySQL Enterprise Monitor & Oracle Enter...
OracleMySQL
 
Simple Way for MySQL to NoSQL
Okcan Yasin Saygılı
 
The MySQL SYS Schema
Mark Leith
 
MySQL Technology Overview
Keith Hollman
 
MySQL in Oracle environment : Quick start guide for Oracle DBA (Part 1)
OracleMySQL
 
Introduction to Apache Hive
Avkash Chauhan
 
Introduction to MySQL Enterprise Monitor
Mark Leith
 
How to integrate Splunk with any data solution
Julian Hyde
 
Ingesting streaming data for analysis in apache ignite (stream sets theme)
Tom Diederich
 
DataStax | Deploy DataStax Enterprise Clusters with OpsCenter (LCM) (Manikand...
DataStax
 
MySQL Monitoring Mechanisms
Mark Leith
 
MySQL Server Defaults
Morgan Tocker
 
Mysql tech day_paris_ps_and_sys
Mark Leith
 
Quick MySQL performance check
Tom Diederich
 
implementation of a big data architecture for real-time analytics with data s...
Joseph Arriola
 
How to Find Patterns in Your Data with SQL
Chris Saxon
 
MySQL Enterprise Edition - Complete Guide (2019)
Keith Hollman
 
Upgrade your javascript to drupal 8
Théodore Biadala
 
Query Optimization with MySQL 5.7 and MariaDB 10: Even newer tricks
Jaime Crespo
 
Protecting your data from SQL Injection attacks
Kevin Alcock
 

Similar to MySQL NoSQL JSON JS Python "Document Store" demo (20)

PDF
20160821 coscup-my sql57docstorelab01
Ivan Ma
 
PDF
Python and the MySQL Document Store
Jesper Wisborg Krogh
 
PDF
MySQL Document Store
Mario Beck
 
PDF
MySQL Document Store (Oracle Code Warsaw 2018)
Vittorio Cioe
 
PDF
MySQL Day Paris 2018 - What’s New in MySQL 8.0 ?
Olivier DASINI
 
PDF
MySQL Document Store - A Document Store with all the benefts of a Transactona...
Olivier DASINI
 
PDF
20201106 hk-py con-mysql-shell
Ivan Ma
 
PDF
MySQL 8.0 - What's New ?
Olivier DASINI
 
PPTX
2018: State of the Dolphin, MySQL Keynote at Percona Live Europe 2018, Frankf...
Geir Høydalsvik
 
PDF
No, wait, not that way! - Real-world lessons from an OBIA 11g implementation
jpiwowar
 
PDF
20151010 my sq-landjavav2a
Ivan Ma
 
PDF
20190713_MySQL開発最新動向
Machiko Ikoma
 
PDF
Node.js and the MySQL Document Store
Rui Quelhas
 
PDF
Oracle Code Event - MySQL JSON Document Store
Mark Swarbrick
 
PDF
MySQL Shell - The Best MySQL DBA Tool
Miguel Araújo
 
PDF
MySQL Shell: the daily tool for devs and admins. By Vittorio Cioe.
Cloud Native Day Tel Aviv
 
PDF
JavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScript
Dave Stokes
 
PDF
MySQL For Oracle Developers
Ronald Bradford
 
PDF
[OSC 2020 Online/Nagoya] MySQLドキュメントストア
Ryusuke Kajiyama
 
PPTX
2019 indit blackhat_honeypot your database server
Georgi Kodinov
 
20160821 coscup-my sql57docstorelab01
Ivan Ma
 
Python and the MySQL Document Store
Jesper Wisborg Krogh
 
MySQL Document Store
Mario Beck
 
MySQL Document Store (Oracle Code Warsaw 2018)
Vittorio Cioe
 
MySQL Day Paris 2018 - What’s New in MySQL 8.0 ?
Olivier DASINI
 
MySQL Document Store - A Document Store with all the benefts of a Transactona...
Olivier DASINI
 
20201106 hk-py con-mysql-shell
Ivan Ma
 
MySQL 8.0 - What's New ?
Olivier DASINI
 
2018: State of the Dolphin, MySQL Keynote at Percona Live Europe 2018, Frankf...
Geir Høydalsvik
 
No, wait, not that way! - Real-world lessons from an OBIA 11g implementation
jpiwowar
 
20151010 my sq-landjavav2a
Ivan Ma
 
20190713_MySQL開発最新動向
Machiko Ikoma
 
Node.js and the MySQL Document Store
Rui Quelhas
 
Oracle Code Event - MySQL JSON Document Store
Mark Swarbrick
 
MySQL Shell - The Best MySQL DBA Tool
Miguel Araújo
 
MySQL Shell: the daily tool for devs and admins. By Vittorio Cioe.
Cloud Native Day Tel Aviv
 
JavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScript
Dave Stokes
 
MySQL For Oracle Developers
Ronald Bradford
 
[OSC 2020 Online/Nagoya] MySQLドキュメントストア
Ryusuke Kajiyama
 
2019 indit blackhat_honeypot your database server
Georgi Kodinov
 
Ad

More from Keith Hollman (9)

PDF
Moodle Moot Spain: Moodle Available and Scalable with MySQL HA - InnoDB Clust...
Keith Hollman
 
PDF
MySQL InnoDB Cluster HA Overview & Demo
Keith Hollman
 
PDF
MySQL Cluster: El ‘qué’ y el ‘cómo’.
Keith Hollman
 
PDF
MySQL Replication: Demo Réplica en Español
Keith Hollman
 
PDF
Meb Backup & Recovery Performance
Keith Hollman
 
PPT
MySQL Una Introduccion Tecnica
Keith Hollman
 
PDF
MySQL Enterprise Backup: PITR Partial Online Recovery
Keith Hollman
 
PDF
A MySQL Odyssey - A Blackhole Crossover
Keith Hollman
 
PDF
Embracing Database Diversity: The New Oracle / MySQL DBA - UKOUG
Keith Hollman
 
Moodle Moot Spain: Moodle Available and Scalable with MySQL HA - InnoDB Clust...
Keith Hollman
 
MySQL InnoDB Cluster HA Overview & Demo
Keith Hollman
 
MySQL Cluster: El ‘qué’ y el ‘cómo’.
Keith Hollman
 
MySQL Replication: Demo Réplica en Español
Keith Hollman
 
Meb Backup & Recovery Performance
Keith Hollman
 
MySQL Una Introduccion Tecnica
Keith Hollman
 
MySQL Enterprise Backup: PITR Partial Online Recovery
Keith Hollman
 
A MySQL Odyssey - A Blackhole Crossover
Keith Hollman
 
Embracing Database Diversity: The New Oracle / MySQL DBA - UKOUG
Keith Hollman
 
Ad

Recently uploaded (20)

PDF
Driving Employee Engagement in a Hybrid World.pdf
Mia scott
 
PPTX
Listify-Intelligent-Voice-to-Catalog-Agent.pptx
nareshkottees
 
PDF
Optimizing Large Language Models with vLLM and Related Tools.pdf
Tamanna36
 
PPTX
apidays Singapore 2025 - Generative AI Landscape Building a Modern Data Strat...
apidays
 
PPTX
How to Add Columns and Rows in an R Data Frame
subhashenia
 
PDF
apidays Singapore 2025 - Surviving an interconnected world with API governanc...
apidays
 
PDF
Using AI/ML for Space Biology Research
VICTOR MAESTRE RAMIREZ
 
PDF
1750162332_Snapshot-of-Indias-oil-Gas-data-May-2025.pdf
sandeep718278
 
PPT
Growth of Public Expendituuure_55423.ppt
NavyaDeora
 
PDF
Technical-Report-GPS_GIS_RS-for-MSF-finalv2.pdf
KPycho
 
PPTX
BinarySearchTree in datastructures in detail
kichokuttu
 
PDF
NIS2 Compliance for MSPs: Roadmap, Benefits & Cybersecurity Trends (2025 Guide)
GRC Kompas
 
PDF
SQL for Accountants and Finance Managers
ysmaelreyes
 
PDF
apidays Singapore 2025 - Building a Federated Future, Alex Szomora (GSMA)
apidays
 
PPTX
big data eco system fundamentals of data science
arivukarasi
 
PDF
OOPs with Java_unit2.pdf. sarthak bookkk
Sarthak964187
 
PPTX
03_Ariane BERCKMOES_Ethias.pptx_AIBarometer_release_event
FinTech Belgium
 
PPT
tuberculosiship-2106031cyyfuftufufufivifviviv
AkshaiRam
 
PPTX
apidays Singapore 2025 - The Quest for the Greenest LLM , Jean Philippe Ehre...
apidays
 
PPTX
Powerful Uses of Data Analytics You Should Know
subhashenia
 
Driving Employee Engagement in a Hybrid World.pdf
Mia scott
 
Listify-Intelligent-Voice-to-Catalog-Agent.pptx
nareshkottees
 
Optimizing Large Language Models with vLLM and Related Tools.pdf
Tamanna36
 
apidays Singapore 2025 - Generative AI Landscape Building a Modern Data Strat...
apidays
 
How to Add Columns and Rows in an R Data Frame
subhashenia
 
apidays Singapore 2025 - Surviving an interconnected world with API governanc...
apidays
 
Using AI/ML for Space Biology Research
VICTOR MAESTRE RAMIREZ
 
1750162332_Snapshot-of-Indias-oil-Gas-data-May-2025.pdf
sandeep718278
 
Growth of Public Expendituuure_55423.ppt
NavyaDeora
 
Technical-Report-GPS_GIS_RS-for-MSF-finalv2.pdf
KPycho
 
BinarySearchTree in datastructures in detail
kichokuttu
 
NIS2 Compliance for MSPs: Roadmap, Benefits & Cybersecurity Trends (2025 Guide)
GRC Kompas
 
SQL for Accountants and Finance Managers
ysmaelreyes
 
apidays Singapore 2025 - Building a Federated Future, Alex Szomora (GSMA)
apidays
 
big data eco system fundamentals of data science
arivukarasi
 
OOPs with Java_unit2.pdf. sarthak bookkk
Sarthak964187
 
03_Ariane BERCKMOES_Ethias.pptx_AIBarometer_release_event
FinTech Belgium
 
tuberculosiship-2106031cyyfuftufufufivifviviv
AkshaiRam
 
apidays Singapore 2025 - The Quest for the Greenest LLM , Jean Philippe Ehre...
apidays
 
Powerful Uses of Data Analytics You Should Know
subhashenia
 

MySQL NoSQL JSON JS Python "Document Store" demo

  • 1. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | MySQL Document Store dirigido a Desarrolladores Keith Hollman MySQL Principal Solution Architect [email protected] DEMO
  • 2. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.
  • 3. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | Install MySQL 8.0 $ export PATH=$PATH:/usr/local/mysql/mysql-shell-commercial-8.0.11-linux- glibc2.12-x86-64bit/bin:/usr/local/mysql/mysql-commercial-8.0.11-linux- glibc2.12-x86_64/bin $ cd /usr/local/mysql/mysql-commercial-8.0.11-linux-glibc2.12-x86_64/bin $ mysqld --defaults-file=my.cnf --initialize-insecure $ mysqld --defaults-file=my.cnf &
  • 4. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | Download & install Mongo $ tar zxvf mongodb-linux-x86_64-4.0.0.tar.gz $ cd /usr/local/mongodb-linux-x86_64-4.0.0 $ export PATH=$PATH:/usr/local/mongodb-linux-x86_64-4.0.0/bin $ mkdir -p /opt/mongo/data mongo/log $ vi mongod.conf systemLog: destination: file path: "/opt/mongo/log/mongod.log" logAppend: true storage: dbPath: "/opt/mongo/data" ... $ mongod --config /usr/local/mongodb-linux-x86_64-4.0.0/mongod.conf
  • 5. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | Download data to import into mongo • https://docs.mongodb.com/manual/tutorial/geospatial-tutorial/index.html • File to be downloaded is: – https://raw.githubusercontent.com/mongodb/docs- assets/geospatial/restaurants.json $ mongoimport DocStore/demo/restaurants.json -c restaurants
  • 6. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | Export data for importing into MySQL • This example is inspired by @datacharmer's work: https://www.slideshare.net/datacharmer/mysql-documentstore • And also: https://www.slideshare.net/lefred.descamps/mysql-document-store-how-to-replace-a- nosql-database-by-mysql-without-effort-but-with-a-lot-gains $ mongo --quiet --eval 'DBQuery.shellBatchSize=30000; db.restaurants.find().shellPrint()' | perl -pe 's/(?:ObjectId|ISODate)(("[^"]+"))/ $1/g' > DocStore/demo/all_recs.json
  • 7. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | • Before we start loading data, let's tail the general_log: $ cd /opt/mysql/8011/data $ tail -100f tail -100f khollman_8011.log • Create the environment within MySQL: $ cd DocStore/demo $ mysqlsh --uri root@localhost session.createSchema('test') use test db.createCollection('restaurants') py import json import re with open ('all_recs.json', 'r') as json_data: for line in json_data: skip = re.match('Type', line) if not skip: rec = json.loads(line) db.restaurants.add(rec).execute() Loading data into MySQL
  • 8. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | • Now the data is imported, let's query it: db.restaurants.find() db.restaurants.find().limit(1) db.restaurants.find().fields(["_id","na me","cuisine"]).limit(2) • Using sql still? For whatever reason: session.sql("show create table restaurants") session.sql("select * from restaurants") session.sql("select * from restaurants limit 2") • Let's update an attribute of the collection, using the id: db.restaurants.modify("_id='55cba2476c 522cafdb053add'").set("cuisine","Itali an") db.restaurants.find("_id='55cba2476c52 2cafdb053add'") Querying data
  • 9. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | Querying data (cont.) • We're ACID, and can still do transactions: session.startTransaction() db.restaurants.remove("_id='55cba2476c522cafdb053add'") db.restaurants.find("_id='55cba2476c522cafdb053add'") db.restaurants.modify("_id ='55cba2476c522cafdb053ade'").set("name", "The Hybrid Lunch") db.restaurants.find("_id = '55cba2476c522cafdb053ade'") session.rollback() db.restaurants.find("_id='55cba2476c522cafdb053add'") db.restaurants.find("_id = '55cba2476c522cafdb053ade'") • Using SQL and formatting: SELECT doc->>"$.name" AS name, doc->>"$.cuisine" AS cuisine FROM restaurants where doc->>"$.cuisine" is not null;
  • 10. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | • Getting data out of the Collection, dynamically: ALTER TABLE restaurants ADD COLUMN borough VARCHAR(20) GENERATED ALWAYS AS (json_unquote(json_extract(`doc`,'$.bo rough'))) VIRTUAL; • same as: ALTER TABLE restaurants ADD COLUMN borough VARCHAR(20) GENERATED ALWAYS AS (doc->>"$.borough") VIRTUAL; • Using MySQL 8.0 CTE: WITH cte1 AS (SELECT doc->>"$.name" AS name, doc->>"$.cuisine" AS cuisine, (SELECT AVG(score) FROM json_table(doc, "$.grades[*]" COLUMNS (score INT PATH"$.score")) AS r) AS avg_score FROM restaurants) SELECT *, RANK() OVER (PARTITION BY cuisine ORDER BY avg_score) AS `rank` FROM cte1 ORDER BY `rank`, avg_score DESC LIMIT 30; Querying data (cont.)
  • 11. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | More examples & Information • https://elephantdolphin.blogspot.com/2018/06/mongodb-versus-mysql- document-store.html • https://mysqlserverteam.com/mysql-8-0-from-sql-tables-to-json- documents-and-back-again/ • https://www.mysql.com/news-and-events/web-seminars/nosql- development-for-mysql-document-store-using-java/
  • 12. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | Preguntas?
  • 13. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |