3.
Safe Harbor Statement
The following is intended to outline our general product direction. It is intended for
information purpose 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 up in
making purchasing decisions. The development, release and timing of any features or
functionality described for Oracle´s product remains at the sole discretion of Oracle.
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
3 / 100
4. about me - http://about.me/lefred
Who am I ?
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
4 / 100
6. MySQL
a Document Store with all the benefits of a RDBMS
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
6 / 100
7. Why ?
Developers don´t really like SQL
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
7 / 100
8. Why ?
SQL can be complicated and slows down the initial development
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
8 / 100
9. easy operations
What do developers want ?
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
9 / 100
10. Use Objects / Documents
Developers want just to use objects
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
10 / 100
11. Use Objects / Documents
Developers want just to use objects
that´s why they usually love what DBAs hate the most ORMs !).
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
11 / 100
12. Use Objects / Documents
Developers want just to use objects
that´s why they usually love what DBAs hate the most ORMs !).
They want to deal with these objects easily (CRUD operations) and they don´t want to
think about schema design (slows down the initial development process).
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
12 / 100
13. Use Objects / Documents
Developers want just to use objects
that´s why they usually love what DBAs hate the most ORMs !).
They want to deal with these objects easily (CRUD operations) and they don´t want to
think about schema design (slows down the initial development process).
But they also want to keep their data safe and use transactions.
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
13 / 100
14. RDBMS & MySQL
Relational Databases
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
14 / 100
22. Relational Databases
Data Integrity
normalization
constraints (foreign keys, ...)
Atomicity, Consistency, Isolation, Durability
ACID compliant
transactions
SQL
powerfull query language
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
22 / 100
23. NoSQL & MySQL
NoSQL Databases
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
23 / 100
24. NoSQL or Document Store
Schemaless
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
24 / 100
25. NoSQL or Document Store
Schemaless
no schema design, no normalization, no foreign keys, no data types, ...
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
25 / 100
26. NoSQL or Document Store
Schemaless
no schema design, no normalization, no foreign keys, no data types, ...
very quick initial development
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
26 / 100
27. NoSQL or Document Store
Schemaless
no schema design, no normalization, no foreign keys, no data types, ...
very quick initial development
Flexible data structure
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
27 / 100
28. NoSQL or Document Store
Schemaless
no schema design, no normalization, no foreign keys, no data types, ...
very quick initial development
Flexible data structure
embedded arrays or objects
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
28 / 100
29. NoSQL or Document Store
Schemaless
no schema design, no normalization, no foreign keys, no data types, ...
very quick initial development
Flexible data structure
embedded arrays or objects
valid solution when natural data can´t be modelized optimaly into a relational
model
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
29 / 100
30. NoSQL or Document Store
Schemaless
no schema design, no normalization, no foreign keys, no data types, ...
very quick initial development
Flexible data structure
embedded arrays or objects
valid solution when natural data can´t be modelized optimaly into a relational
model
objects persistance without the use of any ORM - mapping oobject-oriented
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
30 / 100
31. NoSQL or Document Store
Schemaless
no schema design, no normalization, no foreign keys, no data types, ...
very quick initial development
Flexible data structure
embedded arrays or objects
valid solution when natural data can´t be modelized optimaly into a relational
model
objects persistance without the use of any ORM - mapping oobject-oriented
JSON
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
31 / 100
32. NoSQL or Document Store
Schemaless
no schema design, no normalization, no foreign keys, no data types, ...
very quick initial development
Flexible data structure
embedded arrays or objects
valid solution when natural data can´t be modelized optimaly into a relational
model
objects persistance without the use of any ORM - mapping oobject-oriented
JSON
close to frontend
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
32 / 100
33. NoSQL or Document Store
Schemaless
no schema design, no normalization, no foreign keys, no data types, ...
very quick initial development
Flexible data structure
embedded arrays or objects
valid solution when natural data can´t be modelized optimaly into a relational
model
objects persistance without the use of any ORM - mapping oobject-oriented
JSON
close to frontend
native in JS
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
33 / 100
34. NoSQL or Document Store
Schemaless
no schema design, no normalization, no foreign keys, no data types, ...
very quick initial development
Flexible data structure
embedded arrays or objects
valid solution when natural data can´t be modelized optimaly into a relational
model
objects persistance without the use of any ORM - mapping oobject-oriented
JSON
close to frontend
native in JS
easy to learn
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
34 / 100
35. How DBAs see data
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
35 / 100
36. How DBAs see data How Developers see data
{
"GNP" : 249704,
"Name" : "Belgium",
"government" : {
"GovernmentForm" :
"Constitutional Monarchy, Federation",
"HeadOfState" : "Philippe I"
},
"_id" : "BEL",
"IndepYear" : 1830,
"demographics" : {
"Population" : 10239000,
"LifeExpectancy" : 77.8000030517578
},
"geography" : {
"Region" : "Western Europe",
"SurfaceArea" : 30518,
"Continent" : "Europe"
}
}
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
36 / 100
37. What if there was a way to provide both SQL
and NoSQL on one stable platform that has
proven stability on well know technology with
a large Community and a diverse ecosystem ?
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
37 / 100
38. DBMS or NoSQL ?
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
38 / 100
39. DBMS or NoSQL ?
Why not both ?
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
39 / 100
40. The MySQL Document Store !
SQL is now optional ?!
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
40 / 100
41. SQL is now optional ?!
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
41 / 100
42. Developers:
[x] schemaless
[x] rapid prototying/simpler APIs
[x] document model
[x] transactions
Operations:
[x] performance
management/visibility
[x] robust replication, backup,
restore
[x] comprehensive tooling
ecosystem
[x] simpler application schema
upgrades
Business Owner:
[x] don't lose my data == ACID trx
[x] capture all my data =
extensible/schemaless
[x] product on schedule/time to
market = rapid developement
A solution for all
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
42 / 100
43. MySQL Document Store
the Solution
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
43 / 100
44. Built on
the MySQL
JSON Data
type and
Proven
MySQL
Server
Technology
Provides a schema flexible JSON Document Store
No SQL required
No need to define all possible attributes, tables, etc.
Uses new X DevAPI
Can leverage generated column to extract JSON values
into materialized columns that can be indexed for fast
SQL searches.
Document can be ~1GB
It's a column in a row of a table
It cannot exceed max_allowed_packet
Allows use of modern programming styles
No more embedded strings of SQL in your code
Easy to read
Also works with relational Tables
Proven MySQL Technology
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
44 / 100
46. X DevAPI We provide connectors for
C++, Java, .Net, Node.js, Python, PHP
working with Communities to help them supporting
it too
New MySQL Shell
Command Completion
Python, JavaScrips & SQL modes
Admin functions
New Util object
A new high-level session concept that can scale from
single MySQL Server to a multiple server environment
Non-blocking, asynchronous calls follow common
language patterns
Supports CRUD operations
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
46 / 100
47. PY
JS
SQL
>
MySQL 8.0
Upgrade Checker
Auto Completion
&
Command History
Output
Formats
(table, json, tabs)
Prompt
Themes
Batch
Execution
5.7
8.0
JS
Document
Store
X dev API
SQL CLI InnoDB
Cluster
importJSON
JSJS
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
47 / 100
48. Migration from MongoDB to MySQL DS
For this example, I will use the well known restaurants collection:
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
48 / 100
49. Migration from MongoDB to MySQL DS
For this example, I will use the well known restaurants collection:
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
49 / 100
50. Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
50 / 100
51. Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
51 / 100
64. CRUD operations for collections
Add a document
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
64 / 100
65. CRUD operations for collections
Add a document
collection.add({ name: 'fred', age: 42 })
.add({ name: 'dave', age: 23 })
.execute()
collection.add([
{ name: 'dimo', age: 50 },
{ name: 'kenny', age: 25 }
]).execute()
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
65 / 100
66. CRUD operations for collections
Modify a document
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
66 / 100
67. CRUD operations for collections
Modify a document
collection.modify('name = :name')
.bind('name', 'fred')
.set('age', 43)
.sort('name ASC')
.limit(1)
.execute()
collection.modify('name = :name')
.bind('name', 'fred')
.patch({ age: 43, active: false })
.sort('name DESC')
.limit(1)
.execute()
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
67 / 100
68. CRUD operations for collections
Remove a document
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
68 / 100
69. CRUD operations for collections
Remove a document
collection.remove('name = :name')
.bind('name', 'fred')
.sort('age ASC')
.limit(1)
.execute()
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
69 / 100
70. MySQL Document Store Objects Summary
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
70 / 100
71. All you need to know is here:
https://dev.mysql.com/doc/x-devapi-userguide/en/crud-operations-overview.html
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
71 / 100
72. we do care about your data
MySQL Document Store is Full ACID Compliant
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
72 / 100
73. Document Store Full ACID !
It relies on the proven MySQL InnoDB´s strength & robustness:
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
73 / 100
74. Document Store Full ACID !
It relies on the proven MySQL InnoDB´s strength & robustness:
innodb_ ush_log_at_trx_commit = 1
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
74 / 100
75. Document Store Full ACID !
It relies on the proven MySQL InnoDB´s strength & robustness:
innodb_ ush_log_at_trx_commit = 1
innodb_doublewrite = ON
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
75 / 100
76. Document Store Full ACID !
It relies on the proven MySQL InnoDB´s strength & robustness:
innodb_ ush_log_at_trx_commit = 1
innodb_doublewrite = ON
sync_binlog = 1
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
76 / 100
77. Document Store Full ACID !
It relies on the proven MySQL InnoDB´s strength & robustness:
innodb_ ush_log_at_trx_commit = 1
innodb_doublewrite = ON
sync_binlog = 1
transaction_isolation = REPEATABLE-READ|READ-
COMMITTED|...
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
77 / 100
78. Document Store Full ACID !
It relies on the proven MySQL InnoDB´s strength & robustness:
innodb_ ush_log_at_trx_commit = 1
innodb_doublewrite = ON
sync_binlog = 1
transaction_isolation = REPEATABLE-READ|READ-
COMMITTED|...
We do care about your data !
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
78 / 100
79. MySQL DS Full ACID - Transactions support
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
79 / 100
80. MySQL DS Full ACID - Transactions support
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
80 / 100
81. OK we have Document Store, CRUD and ACID
but what makes MySQL Document Store unique ?
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
81 / 100
82. Challenge: list the best restaurant of each type
of food and show the top 10, with the best one
first !
don't forget that all these restaurants are just JSON documents
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
82 / 100
83. NoSQL as SQL - aggregation
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
83 / 100
84. NoSQL as SQL - aggregation
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
84 / 100
85. NoSQL as SQL - aggregation
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
85 / 100
86. NoSQL or SQL
You have the possibility to write clean and neat code:
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
86 / 100
87. NoSQL or SQL
You have the possibility to write clean and neat code:
$results = $collection-> nd('cuisine like "italian"')->execute()->fetchAll();
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
87 / 100
88. NoSQL or SQL
You have the possibility to write clean and neat code:
$results = $collection-> nd('cuisine like "italian"')->execute()->fetchAll();
Or use SQL only when really needed:
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
88 / 100
89. NoSQL or SQL
You have the possibility to write clean and neat code:
$results = $collection-> nd('cuisine like "italian"')->execute()->fetchAll();
Or use SQL only when really needed:
$results = $session->sql('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 docstore.restaurants)
SELECT *, RANK()
OVER ( PARTITION BY cuisine ORDER BY avg_score) AS `rank`
FROM cte1 ORDER BY `rank`, avg_score DESC LIMIT 10;')->execute();
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
89 / 100
90. NoSQL or SQL
You have the possibility to write clean and neat code:
$results = $collection-> nd('cuisine like "italian"')->execute()->fetchAll();
Or use SQL only when really needed:
$results = $session->sql('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 docstore.restaurants)
SELECT *, RANK()
OVER ( PARTITION BY cuisine ORDER BY avg_score) AS `rank`
FROM cte1 ORDER BY `rank`, avg_score DESC LIMIT 10;')->execute();
All in the same MySQL X Session !
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
90 / 100
91. MySQL Shell is for DBAs and Developers
DEMO
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
91 / 100
92. what do I gain ?
Conclusion
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
92 / 100
93. schemaless
flexible data structure
easy to start (CRUD)
Conclusion
This is the best of the two worlds in one product !
Data integrity
ACID Compliant
Transactions
SQL
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
93 / 100
97. Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
97 / 100
98. May 9th, 2019
Hotel NH Collection Roma
Giustiniano
Via Virgilio, 1 E/F/G, 0019
ROMA
MySQL Day Roma
You are invited to listen last news on MySQL
8.0, watch demos and be in contact with the
MySQL Italian Team!
http://bit.ly/MySQLDayRoma2019
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
98 / 100
99. Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
99 / 100
100. Thank you !
Any Questions ?
share your 💕 for MySQL on social media using @mysql #MySQL8isGreat
#MySQL
Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.
100 / 100