Timothy Boronczyk is a native of Syracuse, NY, where he works as a senior developer at ShoreGroup, Inc. He's been involved with Web technologies since 1998, has a degree in Software Application Programming, and is a Zend Certified Engineer. In what little spare time he has left, Timothy enjoys hanging out with friends, speaking Esperanto, and sleeping with his feet off the end of the bed. He's easily distracted by shiny objects.
About SitePoint
SitePoint specializes in publishing fun, practical, and easy-to-understand content for web professionals. Visit http://www.sitepoint.com/ to access our blogs, books, newsletters, articles, and community forums. Youll find a stack of information on JavaScript, PHP, Ruby, mobile development, design, and more.
Preface
From big data data sets in an enterprise data center to hand-scribbled shopping lists, data is everywhere. Corporations collect as much of it as they can and analyze it to formulate new business strategies. Scientists study data looking for answers that can save lives, improve our environment, and explain our place in the universe. Even the average person maintains a fair amount of data, from ledgers detailing ones spending habits to phone numbers in a cellphones address book. Storing and organizing all of this this data has become so easy that we often take for granted many of the database concepts and algorithms that make these things possible.
This book is an introduction to the basic concepts of working with a Relational Database Management System (RDBMS)specifically, the popular, open source RDBMS MySQL. Like other installments in SitePoints Jump Start series, it aims to give you a head start in your understanding of the chosen technology. Youll learn the basics quickly, in a friendly, (hopefully) pain-free way, and have a solid foundation to continue on in your learning.
Im very grateful to have been given the opportunity to write this book. What separates it from others in the lineup is that it discusses a technology widely used both within and outside the world of web development. Thats not to say MySQL isnt popular with developers creating web-based applicationsquite the contrary! But databases are used in many other areas as well and I've tried to capture this in my selection of topics.
What is a Database?
Although we tend to associate the word database with the digital world of computers, the term simply refers to any organized collection of data. A database can therefore be digital/electronic or physical. The filing cabinet full of financial records that sits in the corner of your home office is a physical database. The cookbooks on your bookshelf, with their dog-eared pages and extra recipes clipped from magazines tucked inside, can also be viewed as a physical database.
In the digital world, databases are classified by how they organize and store their data. Some common types of digital databases are:
Flat file databases these store data sequentially, often in plain text files. They are easy to create and to add data to but they also have several drawbacks. Flat file databases are slow to search, may contain redundant data, and can easily become corrupted. An example of this type of database is the text file created by a solitaire game to store users high scores.
Hierarchical database s these organize data in parent/child relationships. They are highly organized and searching is efficient, but hierarchical databases are difficult to navigate when youre not familiar with their relationships. Maintaining data relationships over time can be difficult as well. The Windows Registry is an example of a hierarchical database.
Key-value/document-oriented databases these store free-form data indexed by a key or hash value. They typically scale across wide network topologies very well but share many of the problems with flat file databases. They often contain redundant data, do not maintain relationships, and searching them can be slow. Redis and CouchDB are popular NoSQL database systems that manage these types of databases.
Relational databases these organize data in rows and tables, much like a printed price list or bus schedule can be organized as a table. Relational databases can support indexing large amounts of data for quick retrieval, but the relationships between tables can become very complex.
Sitting above most modern digital databases is a database server , an application designed specifically for managing databases, and which is responsible for marshaling access to the underlying data. We never work directly with a database in such systems. Instead, we send requests to add, update, remove, or fetch the desired data to the server. The server performs the requested actions on our behalf and forwards the results on to us. The book youre reading right now focuses on MySQL, a database server that manages relational databases.
Since the mid 1980s, Structured Query Language