Acknowledgments . xix
Introduction xxi
PART I: GETTING STARTED . 1
Chapter 1: Installing MySQL and Tools 3
Chapter 2: Creating Databases and Tables 9
PART II: SELECTING DATA FROM A MYSQL DATABASE . 25
Chapter 3: Introduction to SQL . 27
Chapter 4: MySQL Data Types . 37
Chapter 5: Joining Database Tables 51
Chapter 6: Performing Complex Joins with Multiple Tables . 63
Chapter 7: Comparing Values 85
Chapter 8: Calling Built-in MySQL Functions . 99
Chapter 9: Inserting, Updating, and Deleting Data 143
PART III: DATABASE OBJECTS . 157
Chapter 10: Creating Views . 159
Chapter 11: Creating Functions and Procedures . 165
Chapter 12: Creating Triggers 195
Chapter 13: Creating Events 209
PART IV: ADVANCED TOPICS . 217
Chapter 14: Tips and Tricks 219
Chapter 15: Calling MySQL from Programming Languages 237
PART V: PROJECTS 259
Chapter 16: Building a Weather Database 261
Chapter 17: Tracking Changes to Voter Data with Triggers 277
Chapter 18: Protecting Salary Data with Views 301
Afterword 313
Index . 315
With databases lurking in the background of every website, knowing how to manage them with MySQL is a no-brainer. This practical, hands-on introduction teaches readers all they need to know.
MySQL Crash Course is a fast-paced, no-nonsense introduction to relational database development. It’s filled withpractical examples and expert advice that will have you up and running quickly.
You’ll learn the basics of SQL, how to create a database, craft SQL queries to extract data, and work with events,procedures, and functions. You’ll see how to add constraints to tables to enforce rules about permitted data and useindexes to accelerate data retrieval. You’ll even explore how to call MySQL from PHP, Python, and Java.
Three final projects will show you how to build a weather database from scratch, use triggers to prevent errors in anelection database, and use views to protect sensitive data in a salary database.
Query database tables for specific information, order the results, comment SQL code, and deal with null values
Define table columns to hold strings, integers, and dates, and determine what data types to use
Join multiple database tables as well as use temporary tables, common table expressions, derived tables, andsubqueries
Add, change, and remove data from tables, create views based on specific queries, write reusable stored routines, and automate and schedule events
The perfect quick-start resource for database developers, MySQL Crash Course will arm you with the tools you needto build and manage fast, powerful, and secure MySQL-based data storage systems.