Multi-column constraints

Imagine that you have a table in which two columns together form a constraint. For example, you have a category table that has a reference to a section (a different table) and a name. Now, you want that category names should be unique within a section. You can insert any section multiple times, and you can use any name multiple times. But you can not have insert the same section and name multiple times.

How do you about it? Simple, use constraints on a group of columns, of course. It’s just that I didn’t have a clue that this worked until today. I had seen something like UNIQUE(a, b) some time back, but I thought it was just a short-hand for setting unique constraints on multiple columns in one go.

Well, I was wrong. It actually sets up a constraint on the columns as a group. That is so cool! Since my database server assures that I cannot insert a duplicate name within a section, I don’t have write loads of code to do it. In fact, I can trim down my code a bit this evening.

I think I am just about the only person in the whole world who didn’t know about this already. Of course, if I had taken my time to RTFM, I would also have known..

Published in: on 2006.08.31 at 16:04  Leave a Comment  

Ruby vs. Python == WAR!

Now that I have your attention..

There are an increasing number of “Ruby is better than Python” and “Python is better than Ruby” posts all over the Internet. It reminds me of the old KDE vs. Gnome, Vi vs. Emacs, Amiga vs. Atari, C64 vs. Spectrum and many other flamewars of days gone by. I wonder why so many people find it so necessary to criticize things they don’t like. Because at the end of it all, that’s all it is: matters of opinion.

I personally prefer Ruby over Python. But at least I know it’s a personal bias. I spent many years with Perl, and Ruby just feels right for me. But I also love Python. I do program in Python as well, and for certain types of problems I think Python may be a better solution than Ruby, at least for me.

There are good Python programmers who are building excellent solutions in their language of choice. There are good Ruby programmers solving interesting problems in their language of choice. So obviously, neither language is “flawed”, although claims are made from both camps about the “other language” being just that.

To the Ruby crowd: so Python’s OO is “bolted-on” is it? Okay, even if we assume that is true, who cares? The fact is that people are using Python’s OO to do great stuff, bolted-on or not. You don’t like indentation being a part of the syntax? Many people do like it that way. And there is a rationale behind it. To tell you the truth, I’ve never really had a problem with it. Vim auto-indents very well, so I usually don’t worry about it.

To the Python crowd: you don’t like $_? You’re not forced to use it, and many people don’t. You think Ruby allows you to write messy code? Sure it does, but it allows you to write clean code as well. It all depends on the skills of the individual programmer.

If you really want to show off what a great programming language you are using, then use it to build good solutions to interesting problems. Constantly complaining about how some other language is less pure, more difficult, less maintainable, less readable doesn’t really say much about the benefits of your own choice.

Published in: on 2006.08.31 at 12:05  Comments (2)  

Back again

I used to have a blog at, but one fine(?) day, my web host disappeared into the void. Since then I’ve been trying out different blog hosting services, but I’ve none of them really made me happy. I was using WordPress on my site, and I was happy with it.

Then a friend told me about the WordPress blog hosting service here at and a signed up. Now I’m happy and can get back to blogging again!

Published in: on 2006.08.30 at 14:35  Leave a Comment