52 Word Review: Eastern Promises

Viggo Mortenson in David Cronenburg's 'Eastern Promises'Eastern Promises, an exercise in minimalist plot, succeeds due to delicate acting and stoic directing. It’s got the villian, anti-hero, idealist, and the fairly obvious Twist, but saves itself from mediocrity by telling only the important parts of the story. Cronenburg’s films succeed because they leave you with questions, not answers.

Database Naming Conventions

Time for another naming convention. This time it’s something people care more about than Java packages, we’re talking about databases. Here are the rules, and the reasons behind them.

Use lowercase for everything

We’ve got 4 choices here:

  • Mixed case

    • Some servers are case sensitive, some are not. MySQL for example, is case-insensitive for column names, case-insensitive on Windows for table names, but case-sensitive on Linux for table names.
    • Error prone
  • No convention

    • Same reasons as mixed case
  • Upper case

    • SQL is easier to scan when the reserved words are uppercase. This is valuable when scanning log files looking for things like WHERE statements and JOINs.
    • MySQL will always dump table names on Windows in lowercase.
  • Lowercase

    • Works everywhere. Some servers, like Oracle, will appear to convert everything to uppercase, but it’s just case-insensitive and you can use lowercase.

Only use letters and underscores and numbers (sparingly)

  • Most servers support other characters, but there are no other characters which all the major servers support.
  • Numbers should be used as little as possible. Frequent use is typically a symptom of poor normalization.

    • address1, address2 is OK
  • Whitespace isn’t allowed on most servers, and when it is you have to quote or bracket everything, which gets messy.

Table and column should be short, but not abbreviated.

  • You’ve seen the same thing abbreviated every way possible, like cust_add, cus_addr, cs_ad, cust_addrs, why not just customer_address? We’re not writing code on 80 character terminals any more, and most people aren’t even writing SQL, so let’s keep it clear, OK?
  • 30 characters is considered the safe limit for portability, but give some serious thought before you go past 20.

Table names should be singular.

Yes, singular! Oh yes, I went there. I used to use plural names, because it’s more semantically accurate. After all if each record is a person, then a group of them would be people, right? Right, but who cares. SELECT * FROM person isn’t any less clear than people, especially if you’ve got a solid convention. You don’t use plurals when you’re declaring class names for a vector of generics do you? Also:

  • English plurals are crazy, and avoiding them is good.

    • user -> users
    • reply -> replies
    • address -> addresses
    • data -> data (unless its geographic, then it’s datum -> data)
  • Singular names means that your primary key can always be tablename_id, which reduces errors and time.

Double Underscores for Associative Tables.

You’ve got your person table, and your address table, and there’s a many-to-many between them. This table should be called address__person. Why? Well what if you have a legacy_customer table that also ties to address. Now you’ve got address__legacy_customer. A new developer can easily pick up this convention and will be able to break down the names accordingly. Remember, no matter what the Perl/Lisp/Ruby/etc guys say, clarity of code is judged by how someone reads it, not how they write it.

Component Names of Associative Tables in Alphabetical Order.

This rule is somewhat arbitrary, but still beneficial. There’s no good way to determine which goes first. Table size, “importance”, age, who knows what else, and those assessments may change over time. Or, you might find that your manager assigned the same task to two people, and now you’ve got an address__person and a person__address table co-existing peacefully, when you only need one. Everyone putting them in the same order makes reading and writing queries easier.

That’s all I’ve got for now, but I encourage you to offer your own, or even refute some of the ones above (with some reasoning, of course).

52 Word Review: 3:10 to Yuma

3:10 to Yuma3:10 to Yuma is a violent Elmore Leonard western, but unfortunately the setting was rather unimportant to the story. Russell Crowe flashed his trademark smirks, and Christian Bale flexed his trademark angst, in a decent, but relatively unremarkable story of redemption. If you’re hankering for a hunk’o’Western, this should do the trick.

Jet Cars Under the Stars

This wasn’t my first time seeing jet-powered drag racing, but the first since this blog started, so I feel compelled to share. High-end drag racing (jet, top-fuel) is a spectacle I think everyone should witness. It has the veneer of a competitive sport, but most people don’t really care who wins. It’s the violent, brutal, temper-tantrum throwing little brother of the bigger racing sports like F1 (the refined elder sibling), Rally (the insane middle child) and NASCAR (the challenged stepchild), and it needs to be seen in person, no television or movie screen or stereo system can do it justice.

New England Dragway in Epping, NH has a few jet events per year, my preference being “Jet Cars Under the Stars” because as my pictures hopefully show, the jets are much more entertaining in the dark. This years event was marred by poor weather, and a poorly managed delay, but at about 9:30pm, the festivities began. I’ll let the pictures do the rest of the talking here, and you can see more of them here.

The World is a Blur

Jet Ambulance

Jet Train

Jet Funny Car

The Departure

New Toy Review: TeraStation Live

2 TB TeraStation LiveA few weeks ago I picked up 2 TB TeraStation Live, and so far I have to say I’m very happy with it. I got it for $800 from buy.com, which puts the whole device at about $400 over the price of it’s 4 500GB hard drives. I think that premium is well worth it.

It was very easy to set up, at least for someone with a base knowledge of setting up a file share. The administration is done via a slow, clunky, but straightforward and ultimately effective web UI. I have set up a few different shares with varying permissions, and haven’t had any problems so far. Among its nice/key features are the fact that it is virtually silent, has gigabit networking, and isn’t too big, about the size of a mini-tower PC.

52 Word Review: Harry Potter and the Order of the Phoenix

The fifth Harry Potter book, more thriller than adventure, was the one that I think was ghostwritten, and the movie held true to the book, as usual. The three main actors weren’t nearly as horrible as they are in the previous movies, acting lessons finally? Effects: nice. Story: padding for the series.

Domain Ideas

I put “savage” into GoDaddy‘s search box, just to see what would come up, and while savage.com is obviously taken, it suggested some rather entertaining alternatives:

  • WILDDRUNK.COM – Surprised this one isn’t taken by Girls Gone Wild.
  • FERAL4U.COM – A site that matches wild animals with potential owners?
  • HOTFERAL.COM – Which animals are trending in your area?
  • UNCIVILIZEDLIVE.COM – Future site of the world’s largest rock-banging concert.
  • WILDTHIN.COM – The latest diet fad, lose weight by eating berries, running from bears, and getting dysentery.
  • BARBAROUSSTORE.COM – Because pirates and drug lords need pants too.