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
PyConX - Python & MySQL 8.0 Document Store
Frederic Descamps
 
PDF
MySQL without the SQL -- Cascadia PHP
Dave Stokes
 
PDF
MySQL Without The SQL -- Oh My! PHP Detroit July 2018
Dave Stokes
 
PDF
Python and MySQL 8.0 Document Store
Frederic Descamps
 
PDF
MySQL 8.0 Introduction to NoSQL + SQL
Manuel Contreras
 
PDF
20190915_MySQL開発最新動向
Machiko Ikoma
 
PDF
MySQL Tech Café #8: MySQL 8.0 for Python Developers
Frederic Descamps
 
PDF
UAE MySQL Users Group Meet-up : MySQL Shell Document Store & more...
Frederic Descamps
 
PDF
MySQL Document Store - when SQL & NoSQL live together... in peace!
Frederic Descamps
 
PDF
MySQL Document Store -- SCaLE 17x Presentation
Dave Stokes
 
PDF
Cloud native - Why to use MySQL 8.0 and how to use it on oci with MDS
Frederic Descamps
 
PDF
20190713_MySQL開発最新動向
Machiko Ikoma
 
PDF
Python and the MySQL Document Store
Jesper Wisborg Krogh
 
PDF
Oracle Open World Middle East - MySQL 8 a Giant Leap for SQL
Frederic Descamps
 
PDF
the State of the Dolphin - October 2020
Frederic Descamps
 
PPTX
A Step by Step Introduction to the MySQL Document Store
Dave Stokes
 
PPTX
The State of the Dolphin, MySQL Keynote at Percona Live Europe 2019, Amsterda...
Geir Høydalsvik
 
PPTX
2018: State of the Dolphin, MySQL Keynote at Percona Live Europe 2018, Frankf...
Geir Høydalsvik
 
PPTX
MySQL Without the SQL -- Oh My! Longhorn PHP Conference
Dave Stokes
 
PyConX - Python & MySQL 8.0 Document Store
Frederic Descamps
 
MySQL without the SQL -- Cascadia PHP
Dave Stokes
 
MySQL Without The SQL -- Oh My! PHP Detroit July 2018
Dave Stokes
 
Python and MySQL 8.0 Document Store
Frederic Descamps
 
MySQL 8.0 Introduction to NoSQL + SQL
Manuel Contreras
 
20190915_MySQL開発最新動向
Machiko Ikoma
 
MySQL Tech Café #8: MySQL 8.0 for Python Developers
Frederic Descamps
 
UAE MySQL Users Group Meet-up : MySQL Shell Document Store & more...
Frederic Descamps
 
MySQL Document Store - when SQL & NoSQL live together... in peace!
Frederic Descamps
 
MySQL Document Store -- SCaLE 17x Presentation
Dave Stokes
 
Cloud native - Why to use MySQL 8.0 and how to use it on oci with MDS
Frederic Descamps
 
20190713_MySQL開発最新動向
Machiko Ikoma
 
Python and the MySQL Document Store
Jesper Wisborg Krogh
 
Oracle Open World Middle East - MySQL 8 a Giant Leap for SQL
Frederic Descamps
 
the State of the Dolphin - October 2020
Frederic Descamps
 
A Step by Step Introduction to the MySQL Document Store
Dave Stokes
 
The State of the Dolphin, MySQL Keynote at Percona Live Europe 2019, Amsterda...
Geir Høydalsvik
 
2018: State of the Dolphin, MySQL Keynote at Percona Live Europe 2018, Frankf...
Geir Høydalsvik
 
MySQL Without the SQL -- Oh My! Longhorn PHP Conference
Dave Stokes
 
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)

PPTX
Powerful Uses of Data Analytics You Should Know
subhashenia
 
PPTX
Feb 2021 Ransomware Recovery presentation.pptx
enginsayin1
 
PPTX
big data eco system fundamentals of data science
arivukarasi
 
PPTX
apidays Singapore 2025 - Designing for Change, Julie Schiller (Google)
apidays
 
PPTX
BinarySearchTree in datastructures in detail
kichokuttu
 
PPTX
Listify-Intelligent-Voice-to-Catalog-Agent.pptx
nareshkottees
 
PPTX
apidays Helsinki & North 2025 - APIs at Scale: Designing for Alignment, Trust...
apidays
 
PPTX
apidays Helsinki & North 2025 - From Chaos to Clarity: Designing (AI-Ready) A...
apidays
 
PDF
Technical-Report-GPS_GIS_RS-for-MSF-finalv2.pdf
KPycho
 
PDF
apidays Singapore 2025 - Surviving an interconnected world with API governanc...
apidays
 
PPTX
apidays Helsinki & North 2025 - Agentic AI: A Friend or Foe?, Merja Kajava (A...
apidays
 
PPTX
01_Nico Vincent_Sailpeak.pptx_AI_Barometer_2025
FinTech Belgium
 
PDF
Using AI/ML for Space Biology Research
VICTOR MAESTRE RAMIREZ
 
PDF
Data Science Course Certificate by Sigma Software University
Stepan Kalika
 
PPTX
What Is Data Integration and Transformation?
subhashenia
 
PDF
apidays Singapore 2025 - From API Intelligence to API Governance by Harsha Ch...
apidays
 
PPTX
How to Add Columns and Rows in an R Data Frame
subhashenia
 
PPTX
thid ppt defines the ich guridlens and gives the information about the ICH gu...
shaistabegum14
 
PPT
tuberculosiship-2106031cyyfuftufufufivifviviv
AkshaiRam
 
PPTX
Aict presentation on dpplppp sjdhfh.pptx
vabaso5932
 
Powerful Uses of Data Analytics You Should Know
subhashenia
 
Feb 2021 Ransomware Recovery presentation.pptx
enginsayin1
 
big data eco system fundamentals of data science
arivukarasi
 
apidays Singapore 2025 - Designing for Change, Julie Schiller (Google)
apidays
 
BinarySearchTree in datastructures in detail
kichokuttu
 
Listify-Intelligent-Voice-to-Catalog-Agent.pptx
nareshkottees
 
apidays Helsinki & North 2025 - APIs at Scale: Designing for Alignment, Trust...
apidays
 
apidays Helsinki & North 2025 - From Chaos to Clarity: Designing (AI-Ready) A...
apidays
 
Technical-Report-GPS_GIS_RS-for-MSF-finalv2.pdf
KPycho
 
apidays Singapore 2025 - Surviving an interconnected world with API governanc...
apidays
 
apidays Helsinki & North 2025 - Agentic AI: A Friend or Foe?, Merja Kajava (A...
apidays
 
01_Nico Vincent_Sailpeak.pptx_AI_Barometer_2025
FinTech Belgium
 
Using AI/ML for Space Biology Research
VICTOR MAESTRE RAMIREZ
 
Data Science Course Certificate by Sigma Software University
Stepan Kalika
 
What Is Data Integration and Transformation?
subhashenia
 
apidays Singapore 2025 - From API Intelligence to API Governance by Harsha Ch...
apidays
 
How to Add Columns and Rows in an R Data Frame
subhashenia
 
thid ppt defines the ich guridlens and gives the information about the ICH gu...
shaistabegum14
 
tuberculosiship-2106031cyyfuftufufufivifviviv
AkshaiRam
 
Aict presentation on dpplppp sjdhfh.pptx
vabaso5932
 

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. |