Introduction

This book is about SQL, the popular language programmers use for data. Specifically, it’s about the worst ways to use SQL.

Everyone makes mistakes, but experts try to learn from their mistakes, turning them into opportunities to improve their skills. You’ll become a better software developer by studying the most common errors made by other developers, and how to fix them.

My first encounter with SQL involved turning down a job. I had just finished college, and I had been approached by a manager who worked at the university and knew me through campus activities. He had an idea for his own software startup company, and he wanted to develop a database management system portable between various UNIX platforms using shell scripts. He needed a programmer like me to write the code to recognize and execute a limited version of the SQL language.

He said, “I don’t need to support the full language—that would be too much work. I need only one SQL statement: SELECT.”

I hadn’t been taught SQL in any of my college classes. But I had developed complete applications in shell, and I knew a little about parsers and domain-specific languages. So, I thought about taking the job. How hard could it be to parse a single statement of a specialized language like SQL?

As I started to read about SQL, I noticed immediately that this was a different sort of language from those I had used before. To call SELECT only one statement in that language is like calling an engine only one part of an automobile. Both statements are true enough, but they certainly belie the complexity and depth of their subjects. To support execution of that single SQL statement, I realized I would have to develop a fully functional relational database management system and query engine. I could tell it would take years for an experienced developer to do that, and I was still too junior to take on a big project like that by myself.

I declined this opportunity to code an SQL parser and RDBMS engine in shell script. The manager had underestimated the scope of his project, perhaps because he didn’t understand what an RDBMS does.

My early experience with SQL seems to be a common one. Most developers are self-taught in SQL, learning it out of self-defense when they find themselves working on a project that requires it. Whether the person is a hobbyist or a professional programmer or an accomplished researcher with a PhD, SQL is a language that tends to be used by programmers without training. This leads to many common mistakes being made over and over.

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

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