Thursday, March 28th, 2013

One Field With Multiple Values

There are lots of different ways that newbies use to solve the problem where one field in their database is allowed to hold multiple values at the same time. One solution they might use is to provide multiple occurrences of the field (eg phone1, phone2, phone3, phone4) and another is to store all the values [...]

Saturday, January 5th, 2013

GROUP BY and Fields Returned

Depending on just what it is you want to retrieve it can either be really simple to consolidate records in your database or rather complex. Let’s take a look at some of the possibilities and how easy or complex they are to resolve. GROUP BY and Fields Returned

Friday, January 4th, 2013

Sorting Databases

The number of questions I see asking how to retrieve the first so many or last so many entries from the database without specifying what order they want them in gives me the impression that there are lots of people who mistakenly believe that their data is stored in some particular order in the database [...]

Sunday, December 16th, 2012

Images andDatabases

The one type of data that is most likely to be stored separately rather than in the database with the rest of the data are any images. It may or may not be appropriate to have them separate but you should at least consider the pros and cons of actually placing them inside the database [...]

Sunday, October 14th, 2012

Why Normalise a Database

A lot of the common issues that people have with their SQL databases ought to never occur. The only reason they do is that the people who created those databases didn’t do it properly. The first step in designing a database should be to normalise your data and if you do that then many of [...]

Friday, October 5th, 2012

Databases and Null

A variable in a program can contain null as a possible value. A field in a database may also contain null as a possible value. These two are not equivalent though as programs use null as a specific value that the field can contain whereas databases use it to mean that the value is unknown. [...]

Wednesday, October 3rd, 2012

Char or Varchar

When you are defining the fields for your database tables you will have a lot of fields that contain text. In this article we look at the difference between defining those fields as char or varchar and the situations where one may be better than the other. Of course you may be using a database [...]

Sunday, May 27th, 2012

Adding, Replacing, and Deleting Records

All relational databases support the same basic structured query language commands to access and update the database. Of course some of them also have custom extensions to the SQL as well. In this article I look at the basic SQL required for adding, updating, and deleting records in any relational database. Adding, Replacing, and Deleting [...]

Wednesday, February 22nd, 2012

Dates and Databases

Just to get away from JavaScript briefly I wrote this article about how easy it is to convert dates between the internal formats used by PHP and SQL. Two simple PHP commands is all you need. Dates and Databases

Monday, August 2nd, 2010

“SQL Antipatterns”

Developers are not usually database experts and where there isn’t a DBA associated with the team to correct all the “mistakes” that are made in connection with the database you can end up with something inefficient or worse. This book covers many of the common mistakes that developers can make and provides solutions to them. [...]

Tuesday, April 7th, 2009

SQL and Relational Theory

C. J. Date has been around in the field of relaional databases and SQL since the very beginning. In this book he properly introduces those who have learnt SQL to what a relational database is really all about. Read more about what I thing of SQL and Relational Theory.

Tuesday, March 17th, 2009

“Simply SQL”

There are all sorts of different approaches that various books take in teaching structured query language. Even so, the approach this book takes still stands out because it puts everything into a completely different but perhaps far more logical order. “Simply SQL”