« Boston Genius Workshop | Main | OSCON Call for Participation Open »

January 1, 2006

mysql> Says Happy New Year (and more)

As it's New Year's Day (for Gregorian folks), I got to thinking about MySQL and how it might wish folks Happy New Year. Perhaps someday MySQL will be a bit more like HAL and be capable of doing these things on it's own, for now it takes some work on the command-line client prompt to get a response:

mysql> SELECT DAYOFYEAR(NOW()) as 'Day of Year';
+-------------+
| Day of Year |
+-------------+
|           1 |
+-------------+
1 row in set (0.26 sec)

And there you have it, MySQL telling you it's New Year's Day! Not terribly exciting, it's obvious the MySQL doesn't know that day number 1 might be something special to some users. MySQL needs to be a little more concious of culture, perhaps allowing this kind of more direct question:

mysql> SELECT ISNEWYEARSDAY();
+-----------------+
| ISNEWYEARSDAY() |
+-----------------+
|               1 |
+-----------------+
1 row in set (0.00 sec)

Getting closer, but let's think about when you walk down the street in a friendly mood on a special holiday. If interactions with passers-by were strictly boolean there wouldn't be much of a holiday feeling in the air now would there. If every passer by asked "Is it New Years Day?" and you said "Yes" there certainly would be a knowledge of the fact that it is a holiday, but where is the friendliness?

When it comes to special days, MySQL really needs to be able to be more expressive. Let's take it up a notch and ask it to give us an English greeting:

mysql> SELECT GREETING() as 'Greeting';
+----------------+
| Greeting       |
+----------------+
| Happy New Year! |
+----------------+
1 row in set (0.00 sec)

Yes, that is better. You still have to say "Give me a Greeting," but at least it says something respectable. Let's change the date around a bit and see what else it will tell us (I did this by changing the date on my computer).

On December, 26th:

mysql> SELECT NOW() as Date, GREETING() as 'Greeting';
+---------------------+-------------------------+
| Date                | Greeting                |
+---------------------+-------------------------+
| 2005-12-26 16:10:12 | Good Boxing Day to You. |
+---------------------+-------------------------+
1 row in set (0.00 sec)

Now that's getting better, let's try February 14th:

mysql> SELECT NOW() as Date, GREETING() as 'Greeting';
+---------------------+-------------------------------------------+
| Date                | Greeting                                  |
+---------------------+-------------------------------------------+
| 2006-02-14 16:11:43 | Love is in the Air...Happy Valentines Day |
+---------------------+-------------------------------------------+
1 row in set (0.10 sec)

Oh, and even a little extra there.

Now, there are a lot of holidays, and MySQL will need to be localized for various cultures. However holiday-packad a culture is, there will be days where there's just nothing special to announce and as much as MySQL will want to have a pleasant greeting, it will have to say something else, as it does here on January 3rd:

mysql> SELECT NOW() as Date, GREETING() as 'Greeting';
+---------------------+------------------------------------+
| Date                | Greeting                           |
+---------------------+------------------------------------+
| 2006-01-03 16:14:25 | Just an ordinary day, get to work! |
+---------------------+------------------------------------+
1 row in set (0.00 sec)

Next . . . getting MySQL to be friendly without being prompted, and to speak, but not attempt to take over like HAL.

(source for the GREETING() function coming soon, when it's not a holiday where the family is putting pressure on to come have dinner)

Posted by mike at January 1, 2006 3:19 PM