See StructuredQueryLanguage.
SQL is an extraordinarily simple language. It has basically only 4 commands, thus it is very funny that some proposed technologies want to insulate developers (especially the object oriented developers) from the hairy-scary 4 commands language.
The number of commands is a bad metric for language complexity, moreso because most of SQL is actually under the command "SELECT". Functional languages do take learning despite having zero commands.
Besides, just getting things done is SQL is often not what is most important to developers. Integrity, authorisation, concurrency and performance are often of great importance, and these are all concerns that cannot be put solely on the DBA. When you do actual work with SQL databases, you need much more commands than 4.
However, SQL is not worry free, inspite being so simple.
Major areas of concerns:
- The model of SQL databases is not the relational model, it is close but not quite. This induces a false sense of security that when you are using SQL you have a solid mathematical foundation behind you. No, you don't have it quite.
- In SQL you can say the same thing in various differents ways. There are cases documented where you can specify a query in 12 different ways. Or at least that's what it looks like, because you might get slightly different results. Particularly you have to be aware of subqueries, EXISTS and IN operators, outer joins, and the use of NULLs.
- SQL has NULLs. A NULL in SQL is not quite the same as the usual null in a language with references or pointers, and the concept of NULL in SQL has a wide potential for abuse, including in the SQL standard itself. The abuse of NULLs has the damaging potential of leading to incorrect results to queries.
The good thing is that a judicious use of SQL allows you to be in the proper relational model and avoid inconsistencies. However, this has to be done only through self imposed discipline, while I hope that in the future database vendors will be able to enforce a proper subset of SQL that is checked by the query engine.
I'll try to create a small set of patterns about the safe usage of SQL.
CostinCozianu
See also: SqlFlaws
CategorySqlProgramming