SwanseaCon 2017 presentation on Making MySQL Agile-ish. Relational Databases are not usually considered part of the Agile Programming movement but there are many new features in MySQL to make it easier to include it. This presentation covers how MySQL is moving to help support agile development while maintaining the traditional 'non agile' stability expected from a database.
2. About me
Dave Stokes David.Stokes@Oracle.com
MySQL Community Manager
Programming for nearly forty years (FORTRAN, punch cards, batch)
Justin, Texas
@Stoker https://elephantdolphin.blogger.com slideshare.net/davidmstokes
2
3. 22 Years Old
MySQL 5.7
● Best received release yet
● JSON Data Type
● Security
Plug-ins for New Features
● Document Store
○ MySQL without the SQL
● Group Replication
MySQL 8 -- Release Candidate 1
● Data Dictionary
○ No more .frm, .myi, etc files
○ Good: Millions of tables in a database
○ Bad: Millions of tables in a database
● UTF8MB4
● Invisible Indexes
● Windowing Functions, CTEs
● Improved performance
3
6. 1970s
Top Down Design
Disks expensive & slow, memory expensive
Structured Query Language
- Efficiently store data data with a
minimum of duplication
- Set Theory and Relational Calculus
6
5 megabyte drive
7. You end up spending a lot of time architecting
data and trying to foresee all possible options,
outcomes, and variations.
Which always worked perfectly and never, ever
needed to updates, changed, revised or
appended. NOT!
Modifying a database is expensive, time
consuming, and usually single threaded. Usually
to be avoided at ALL costs, postponed as long as
possible.
7
8. 2010s
Code First Design
Disks are not slow/expensive
Memory not expensive
NoSQL
● Store data first (and not sure what is in there)
● Data Warehouse to Digital Landfill
Programming Style Changes
● Embedding SQL looks messy
● OO finally gets a toe hold
8
9. Odd Revolution in Relational Database Management Systems
Much of the world’s data is relational in nature and benefits greatly from
having logical operators (AND, OR, XOR)
Big impact from NoSQL databases
Cost model becomes dynamic to support new store types
JSON as a data type -- Oracle, SQL Server, MySQL, and PostgreSQL has 2!
9
11. Manifesto for Agile Software Development
Individuals and interactions over processes and
tools
Working software over comprehensive
documentation
Customer collaboration over contract negotiation
11
14. Database Work Arounds?
ORMs
Extra layer, often poor performance,
usually easier to write ‘good’ SQL
Undefined Predefined Columns
‘This space left intentionally blank’
Child Tables
Define as you go
14
16. MySQL 5.7 changes
JSON Data Type
Valid JSON document of upto ~1GB
Document Store Plug-In
MySQL without SQL
XDevAPI
Non-blocking, asynchronous calls follow common host language
patterns
16
17. MySQL Document Store
MySQL can now be used as a document store, which is a schema-less, and therefore schema-
flexible, storage system for documents.
When using MySQL as a document store, to create documents describing products you do not
need to know and define all possible attributes of any products before storing them and
operating with them.
This differs from working with a relational database and storing products in a table, when all
columns of the table must be known and defined before adding any products to the database.
You can configure how to use MySQL, using only the document store model, or combining the
flexibility of the document store model with the power of the relational model.
17
18. The new MySQL Shell
Welcome to MySQL Shell 1.0.9
Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help', 'h' or '?' for help, type 'quit' or 'q' to exit.
Currently in JavaScript mode. Use sql to switch to SQL mode and execute
queries.
mysql-js>
18
19. The new MySQL Shell
mysql-js> connect root@localhost/world_x
Creating a Session to 'root@localhost/world_x'
Enter password: ******
Node Session successfully established. Default schema `world_x` accessible
throu
gh db.
mysql-js>
19
20. The new MySQL Shell
mysql-js>db
<Schema:world_x>
mysql-js>db.getCollections()
[
<Collection:countryinfo>,
<Collection:foobar>
]
msyql-js>
20
21. The New MySQL Shell
mysql-js> db.foobar.find().limit(1)
[
{
"Last": "Stokes",
"Name": "Dave",
"Shoe": 49,
"_id": "ccf23cf437e5d211bc0564006a66bb08",
"sneeches": [
"Sylvester McMonkey McBean"
],
"xyz": 1234
}
]
1 document in set (0.07 sec)
mysql-js> 21
23. JSON Data Type
Must be a valid JSON Document
UTF8MB4
~1GB of storage
Can not be indexed directly
23
24. Generated Columns
Columns created via some manipulation
Sales_price = unit_cost * VAT_rate;
Two types
Virtual - created when read
Stored - Materialized when created, better for indexes!
ALTER TABLE `twitter_handle`
ADD COLUMN `location` VARCHAR(255) AS (response->>"$.twitter") STORED;
24
25. MySQL 8
No more .FRM, .MYI, .MYD files!! Meta data in the database!!
Good News: You can now have millions of tables in a schema!
Bad News: You can now have millions of tables in a schema!
Better ‘out of box experience’
UTF8MB4
Plus More
25
26. Start with JSON, Try MySQL 8
Use JSON for schema-less data
Use Generated Columns for items that need to be indexed
Normalize as needed
Take advantage of new features in server (data dictionary, hints, roles)
26
27. Problems with schema-less data
No rigor to data
Size, type, spelling
-- email, eMail, e-mail ….
Can be very unorganized
Speed/Scaling
Legacy -- systems, management, & legal
27