Charles Bell
Introducing the MySQL 8 Document Store
Charles Bell
Warsaw, Virginia, USA
ISBN 978-1-4842-2724-4e-ISBN 978-1-4842-2725-1
Library of Congress Control Number: 2018945864
© Charles Bell 2018
This work is subject to copyright. All commercial rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein.
Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail [email protected], or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.

I dedicate this book to the open source enthusiasts of the world who make the MySQL ecosystem strong. Live long and prosper, Sakila!

Introduction

NoSQL has been given a lot of hype in recent years. As with most new technologies, the underlying principles are rarely truly new, rather, it is the unique combination of known technologies that forms and transforms the whole to become more than the sum of its parts. This is especially true for MySQL 8 and the new MySQL Document Store. Never has MySQL offered so much for so many. Whether you want a traditional relational database solution with a strong foundation or you want the ultimate flexibility to store JSON documents in a document store—or anywhere in between, MySQL can do it.

The trick then is learning how to migrate your applications using each of these technologies: whether you use traditional tables with fixed schemas or you have some JSON fields to allow some freedom from rigid structure or you employ the flexibility of a JSON-based document store.

This book will give you the knowledge you seek to navigate the MySQL Document Store including how to migrate existing applications and best practices for using a document store solution.

Intended Audience

I wrote this book to share my passion for the new MySQL Document Store and Python. I especially wanted to show how anyone can write document store solutions without investing in learning a large, complex language and development environment. The intended audience therefore includes anyone interested in learning about the MySQL Document Store such as database administrators, developers, and information technology managers and strategic planners.

How This Book Is Structured

The book was written to guide the reader from a general knowledge of the new features in MySQL 8 to detailed explanations of the components that make up the MySQL Document Store. The first several chapters cover general topics including a short introduction to MySQL 8, how to install MySQL 8, and how to configure the new document store components. Later chapters present more detailed coverage of the MySQL Document Store components including the MySQL Shell, X DevAPI, X Plugin, and more. Following those chapters is a pair of chapters that present an example application for storing information on books written as a relational database, a hybrid, and a document store. Thus, you can see how to migrate a single application through those variants. The book concludes with some notes about upgrading to MySQL 8 and best practices for using the MySQL Document Store including a recap of the migration process. The following is a brief overview of each chapter included in this book.
  • Chapter 1 , “Introducing MySQL 8—A New Beginning”: This chapter explores some of the highlights of the new MySQL server version 8.0. You will discover those features originally introduced in earlier versions that have been adapted to the new paradigm that is version 8.0, features that are new, and those new features that are truly revolutionary such as the document store, Group Replication, and InnoDB Cluster.

  • Chapter 2 , “Getting Started with MySQL”: This chapter presents a tutorial on MySQL discussing the power of using the MySQL database server in its traditional role using the SQL interface; how to issue commands for creating databases and tables for storing data as well as commands for retrieving that data. Although this chapter presents only a small primer on MySQL, you will learn how to get started with your own installation of MySQL.

  • Chapter 3 , “JSON Documents”: This chapter explores the JSON data type in more detail. You will see examples of how to work with the JSON data in relational tables via the numerous built-in JSON functions provided in MySQL. The JSON data type is key to allowing users to develop hybrid solutions that span the gulf of SQL and NoSQL applications.

  • Chapter 4 , “The MySQL Shell”: This chapter demonstrates how to use the MySQL Shell including a look at the startup options, shell commands, connections, sessions, and we even how to do a bit of interactive scripting in JavaScript and Python. This chapter therefore is the key chapter for learning how to get started with the MySQL Shell and working with JSON and relational data. Although this chapter is not an exhaustive coverage of all the features of the MySQL Shell, it provides a broad tutorial for how to use it for the most common tasks.

  • Chapter 5 , “X Developer API”: This chapter explores the X DevAPI and examines the major classes and methods available for connecting to the MySQL server, creating collections, working with results, and even how to work with relational data. Finally, you will see a set of quick references tables that you can use as the primary reference for developing document store applications.

  • Chapter 6 , “X Plugin”: This chapter discusses the X Plugin and how it works. In particular, you will see how to configure the X Plugin such as changing the port and enabling secure connections via SSL that are separate from the server. The chapter also presents some of the other system variables as well as a lengthy list of status variables that you can use to monitor the X Plugin.

  • Chapter 7 , “X Protocol”: This chapter examines the X Protocol starting with the motivations for why it was created, the chief tenets or goals of the design, and how it was implemented using protobuf as the foundation. You will see a walkthrough of how portions of the X Protocol work for simple use cases. The chapter also presents an example of how to use protobuf in our applications for moving data (messages) around in the code (on disk, over the wire, etc.), which illustrates the power of protobuf.

  • Chapter 8 , “Library Application: User Interface”: This chapter presents a web application library for Python named Flask. You will learn how Flask is built as an extensible framework that is easily augmented with components to make your application more robust. The chapter also presents an introduction to the user interface for the library application built on the foundations of what we learned about Flask.

  • Chapter 9 , “Library Application: Database Implementations”: This chapter explores the differences between a relational database solution and a relational database solution augmented with JSON fields, and finally a pure document store solution. This chapter demonstrates how to build applications for any of these solutions with complete code that demonstrates many of the tenets of the X DevAPI and the MySQL Document Store.

  • Chapter 10 , “Planning for MySQL 8 and the Document Store”: This chapter presents some strategies for migrating to MySQL 8 including considerations and best practices for migrating applications to use the document store with another example of migrating existing database applications. The chapter concludes with some tips and tricks for working with MySQL 8.

How to Use This Book

This book is designed to guide you through learning more about MySQL 8, JSON, the MySQL Document Store, discovering the power of X DevAPI, and learning how to migrate existing and building new document store applications.

If you are new to MySQL, you should spend some time going through the first four chapters including installing MySQL on your own system and learning how to use the MySQL Shell.

If you are familiar with Python and have used the X DevAPI via the MySQL Shell, you may want to read the chapters on the X DevAPI skimming through the examples. On the other hand, if you have not used the X DevAPI or Python, you should attempt to reproduce all the code examples in the chapters.

Once you are familiar with MySQL and the X DevAPI from reading the first seven chapters, you can work through Chapters 8 and 9 that present a complete solution that demonstrates how to build a relational database solution, the same solution as a hybrid relational table with JSON columns, and a migration to a full document store solution.

Planners may find Chapter 10 especially helpful in planning to upgrade to MySQL 8 and to adapt the MySQL Document Store to your infrastructure.

Downloading the Code

The code for the examples shown in this book is available on the Apress web site, www.apress.com . You can find a link on the book’s information page on the Source Code/Downloads tab. This tab is in the Related Titles section of the page.

Contacting the Author

Should you have any questions or comments—or even spot a mistake you think I should know about—you can contact me at [email protected].

Acknowledgments

I thank all the many talented and energetic professionals at Apress. I appreciate the understanding and patience of my acquisition editor, Jonathan Gennick, and coordinating editor, Jill Balzano. They were instrumental in the success of this project. I also thank the army of publishing professionals at Apress for making me look so good in print with a special thank you to the reviewers for their wise council and gentle nudges in the right direction. Thank you all very much!

I also am indebted to the technical reviewer for his insight and guidance in making this book the best book on the new MySQL Document Store.

Most important, I thank my wife, Annette, for her unending patience and understanding while I spent so much time with my laptop.

Table of Contents

Index525

About the Author and About the Technical Reviewer

About the Author

Charles Bell
../images/432285_1_En_BookFrontmatter_Figb_HTML.jpg

conducts research in emerging technologies. He is a member of the Oracle MySQL Development team, and is a senior software developer for the MySQL Enterprise Backup team. He lives in a small town in rural Virginia with his wife. He received his doctor of philosophy in engineering from the Virginia Commonwealth University in 2005.

Charles is an expert in the database field and has extensive knowledge and experience in software development and systems engineering. His research interests include 3D printers, microcontrollers, three-dimensional printing, database systems, software engineering, and sensor networks. He spends his limited free time as a practicing maker, focusing on microcontroller projects and refinement of three-dimensional printers.

 

About the Technical Reviewer

Paulo Jesus
../images/432285_1_En_BookFrontmatter_Figc_HTML.jpg

is currently a principal software developer at Oracle, in the MySQL Engineering Team. He obtained his PhD in distributed systems in 2012, from the MAP-i doctoral program in computer science by the Universities of Minho, Aveiro, and Porto (Portugal). He also has a MSc degree in mobile systems (2007). His research interests include distributed algorithms, fault tolerance, and mobile systems.

 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.179.35