What I hate about SQL
Let’s say you’re doing some database work for Mr. T. You need to keep track of the foo’s he pities, so you create table foo, with columns id and name.
You also need to keep track of where the foo’s drink, so you make table bar, with column foo that links to foo. In SQL, the best you can do is create a foreign key that restricts the data and (I think) speeds up some queries.
Now you want to grab some data so you run something like:
SELECT foo.name, bar.name FROM foo, bar WHERE foo.id = bar.foo AND bar.id = @barID
Or:
SELECT foo.name, bar.name FROM bar INNER JOIN foo ON foo.id = bar.foo WHERE bar.id = @barID
When you all really want is:
SELECT bar.foo.name, bar.name FROM bar WHERE id = @barID
Not only is this much shorter and easier to write, but it’s far easier to read and understand, and would probably be faster. If bar.foo could be an actual reference to a row in foo, instead of just a constraint, the query wouldn’t need to look through foo and anyone reading the query can immediately see that you’re trying to get a list of the foo’s who visit a particular bar.

