Development

Do I need a primary key and should it be called id?

While working with databases – especially Mysql – most people seem to ask the same question over and over again when it comes to Primary Keys. Here’s my typical answer to the question(s) above (and more). Do I need a primary key? No, you don’t need it, but if you haven’t got one, there’s probably something wrong with your data model. A primary key is the unique key to a row in a table.

MVC for PHP

With the amazing buzz around RubyonRails, everyone seems to be hooked on the Model-View-Controller (or just MVC) paradigm – and do strive to mindlessly implement the ”Ruby way” into other programming languages without too much reflection and thoughts on how to do it. . Even tough most of the efforts I’ve seen so far seem pretty hopeless; I do believe you could actually do something good with MVC and PHP. Let me try to tell you how.

QuickSilver

I finally get it. QuickSilver that is. Its an application for the Mac OSX and is the best friend any OSX Power User can have. I’ve downloaded it a couple of times, tried to figure what it was and uninstalled it – but not any more. It’s just great and ought to be build into the OSX. QuickSilver is sort of a power tools basically has made my muse workless today.

Coding style

I usually edit more code others made, than I create new files, and while most of the code is in PHP, there’s a huge difference in the coding style applied by different developers, and some styles are much more annoying than others. I do respect that people are different and that is probably more efficient to allow for some degree of personal style than to try to enforce a single common style.

Emptying mysql tables

There are actually two ways to wipe a mysql table either using delete or using truncate – which is better and why? So far my most commonly used form to wipe a table has simple been by using: DELETE FROM tablename; which works fine for most cases, but mysql also offers a different method: TRUNCATE tablename; Besides the fact that it seems to be faster (even on small tables with few rows) – which in itself is a reason to favour this method - it also has another nice feature, which may be desirable.