Book Review : MySQL & mSQL

 Alessandro Rubini  O'Reilly  £24.99
22 Chapters in 421 Pages.

Contents

Chapters

        1    Introduction to Relational Databases
        2    Database Design
        3    Installation
        4    MySQL
        5    mSQL
        6    SQL according to MySQL and mSQL
        7    Other Mid-Range Database Engines
        8    Database Application Architectures
        9    CGI Programming
        10  Perl
        11  Python
        12  PHP and Other Support for Database-driven HTML
        13  C and C++
        14  Java and JDBC
        15  SQL Reference
        16  MySQL and mSQL System Variables
        17  MySQL and mSQL Programs and Utilities
        18  PHP and Lite Reference
        19  C Reference
        20  Python Reference
        21  Perl Reference
        22  JDBC Reference
 

    Synopsis

As usual with O'Reilly, this is a book that tries to be all things: the first section is intended as an introduction to databases, from chapter eight the subject changes to building useful applications with SQL engines, and finally the tail-end of the book is intended as a reference work. Generally, this division works quite well. It means that regardless of the experience you have, it is likely that some part of this book will be useful to you. And, if having started from knowing nothing, this book will last a long time as it's use changes from instructional text to reference work.

The primary aim of this book is to create database-driven applications, and the main focus is on databases as web engines. A lot of emphasis is placed on the CGI web interaction, and again, this is probably a good idea - MySQL and mSQL in particular are being used all the time to drive interactive web sites, and to be honest most people buying this book will be buying it for these sort of applications. It discusses a good number of bindings, including Perl, Python, PHP and C, which covers all the main languages used for cgi-bins. However, it's not just for web development - these database engines can be used for any sort of access, although people looking to write 'normal' applications may find the internet slant of the book a little disconcerting. But, really, if you're looking to learn to use the MySQL/mSQL tools, learn about relational databases, and especially if you're looking to develop a database-driven website (for e-commerce, etc.), you're probably not going to find a better book than this.

    Review

Most people, when databases are mentioned, generally remember the flat-file system of yore. Each datum was placed on a card, which contained a form to contain all the relevant database. A database was then made up of a set of these cards, which could be searched, browsed, etc., just like the old library system. The limits of this type of database were quickly reached on the computer; it was found that a more structured system was needed, something that better represented the structure of the data it was trying to store. Hence the 'invention' of relational databases.

Relational databases are a funny breed. If you're using a database, it's more than likely a relational one. The likelihood of that database being setup correctly, though, is rather slim. The problem is that they're quite complicated in some ways, and this is exacerbated by database programs such as Microsoft Access, which have their own sweet way of doing things, often to the contrary of the standard conventions. This book, from the very beginning, starts to teach good database design. Normalization, generally known as the process of making a database sensible, is covered very comprehensively. Normalization attempts to remove from databases things you don't want: for example, repetitious data, or making sure all identifiers are unique. There are several 'levels' to this: first normal form, second normal form, etc., each representing a 'cleaner' data relationship. Although these are somewhat complicated ideas for those who have never come across them before, the explanation is generally clear and understandable.

Having taught some elementary database design, the book then proceeds to cover the differences between the two database engines in question (MySQL and mSQL), and their installation and configuration. The general concept of SQL (Structured Query Language) is also discussed in-depth - for a lot of people, this may be knowledge that they already have, but it's always good to cover old ground, because invariably there's gaps in your knowledge.

The book really starts getting interesting when actual application examples are shown. This starts off with an overview of CGI, and how the http GET / POST methods are used to transfer state information over the stateless http protocol. Very soon, the authors have dusted off a Perl script and shown exactly how it is possible to write a cgi-bin that can interface to a database engine, and just how easy it is to write a dynamic, interactive web site. If you're somebody looking to get into the e-commerce scene, setting up online shops / malls, from my experience of developing such sites I can say that this book will be invaluable.

If you're developing a site with access to the Apache web server, you'll be pretty much laughing. Although 99% of this book will transfer to other server platforms, I know of no other server which will support the use of Perl, Python, PHP, C, C++ and Java - if you're using Apache, everything in this book will be relevant to you, if not, there may be some sections (such as PHP) which are of no use. That said, the coverage of a large number of languages and bindings is admirable - the authors make no attempt to second guess your favourite language, nor do they try to enforce their own choice upon the reader. All the examples are well-coded, and good attention is given to error-checking and (especially) cgi security.

The section on Java and the JDBC is particularly interesting. Java server programming has taken off in recent years, and there is a lot of support for Java in a lot of web servers. I'm not sure why this is - perhaps it's the enhanced security that Java offers, or perhaps people are finally realising how awful Perl is (in the reviewer's humble opinion, of course!) - but, nevertheless, it's interesting to see how a language which most people know more for the little animated gadgets on web-pages is being used in mission-critical applications, as e-commerce is for many companies.

The final section of this book is a reference section. It covers everything that is talked about in the book: from a SQL reference to API references and more. Once you've finished learning everything about databases, this book still has a lot to offer as a reference work - I'm sure it's something that the readers of this book will turn to time and time again. The references are particularly comprehensive, and make up a good proportion of the overall length of the book.

All in all, I would heartily recommend this book to anyone looking to learn about relational databases, and the two most common implementations under Linux. I would especially recommend this book to web developers - even if you've only learnt HTML up 'til now, you'll soon realise that with a little bit of programming it's incredibly easy to develop an excellent interactive site that has traditionally been the preserve of the big web development agencies. The book is clear and concise, as always with O'Reilly, and the examples are full and relevant. If you've ever read an O'Reilly book before, you'll know what to expect: this is another quality title in the O'Reilly stable. For those who've never read an O'Reilly title, this is a great place to start!

Review by Alex Hudson