Categories
Programming

Normalized Data ISN’T for Sissies

Today, Jason Kottke, a highly popular blogger, posted an entry titled Normalized data is for sissies. He’s usually very on pointe, but this entry was way off base.

From his article:

Something that’s always confused me is the near-religion of data normalization among programmers and database admins. Every developer I’ve ever worked with has told me that when you’re building a database, you need to normalize your data — basically this means organizing your data in such a way that removes redundancy — and failure to do so would result in public ridicule and possible revocation of access to any computing device. But I’ve always wondered, given that hard drives are cheap and getting cheaper, what’s the problem with using more storage space in exchange for greater speed?

To me, he’s missing the point entirely. Normalization isn’t about saving hard drive space. It’s about ensuring the integrity of the data. It’s about using database capabilities to making applications easier to manage and maintain. Any small speed benefits derived from non-normalized data disappear quickly when an application has to start sorting through redundant data.

I don’t think Mr. Kottke has ever had to work with a database that wasn’t normalized. Or with a database in which an unnormalized table has 100+ columns of which most are empty — it’s hellish to maintain. Or had to clean up a large application with lots of redundant data.

On the surface, normalization may seem more complex. And, yes, fifth normal form is a little crazy. However, sensible normalization is absolutely essential to maintaining data integrity in an application.

Categories
Geek Programming

mish-mash

You know you’ve programmed too many hours in the last week if — when typing an email, you type "(I think snarkiness can be excused in this instance());"

Blogging things bothering me:

  • People who use the MTRedirect plugin to fight spam, but fail to also then put the commenter’s email or website URI in the title attribute of the link.
  • Commenters that use the same name as the site owner for their comment name. Dude, if the site owner is Mike (and he always signs his comments as Mike), then don’t use Mike as your name. You can be Mike #2, or Mikey, or Michael, but you cannot be Mike.
  • As a corollary to the above, if you are new to a site, lay low for a couple days and check out the common commenter names. If there is already a Joe, sign your comment as something else. I mean it’s just proper blog etiquette.
  • This doesn’t really fit in the list, but kudos to the people that already constantly follow this etiquette
Categories
PHP Programming

Advanced PHP: eval()

I thought I’d share a handy trick I came across recently. Most people know of the handy Javascript eval(), but PHP has one of its own up its sleeve. My situation involved needing to capture the result of a PHP script for inclusion into content I was rendering in a Smarty plugin. The content I was creating would then be passed back for inclusion into the compiled template. My problem was that I was basically three levels deep in code parsing. What to do? Use the eval() function.

Example:

<?php
    //send result of php script back
    $num = 3;
    eval("include 'http://www.example.com/myScript.php?num=$num';");
?>

I should note that by default the result of eval() is sent directly to the browser. If you want to capture the result, do something like the following:

<?php
    //capture results of eval()
    $num = 3;
    
    ob_start();
    eval("include 'http://www.example.com/myScript.php?num=$num';");
    $result = ob_get_contents();
    ob_end_clean();
?>

The eval()function can be used in many situations, of course. For one, you might have PHP code stored in a database that is rendered and included dynamically in a script.

Also, be sure that the string you pass contains all valid syntax including semicolons.

Categories
Geek Open Source Programming Website

WordPress 1.2

I finally got WordPress 1.2 installed as a dev blog. I have imported all previous MT entries. Soon I’ll put in the time and effort to get the templates set up in my stripped-down mode.

But, it probably won’t happen this weekend as it is a holiday weekend, after all.

Categories
Geek Programming

please think of the children

This could possibly be the most offensive, horrible, and explicit piece of code I have ever seen:

<center>
       <blink>
             <b><font color="#ff3333">
                  Help us Help you, renew your registration by mail!
             </font></b>
       </blink>
</center>

[Source: Lewis & Clark County website ]

Categories
Geek Programming

a simpler time

Any loyal reader knows my thought processes are random and chaotic. Last night (or this morning, rather) I woke up from a disturbing dream. After somewhat processing it, my mind moved on to Troy. A short time later (and mind you, this was at about 4:30 in the morning), I had a great longing to code a struct.

Structs are so useful, so perfect, and so simple. They especially seemed so at 4:30 in the am this morning.

Categories
Perl

perl tips in case you tend to forget things like I do

So, you want to test string equality in Perl? You just use ‘==’ right? Wrong. In Perl, that will only test number equality which could cause a few problems and inconsistencies.

The Wrong Way:

$mystring = "";

# wrong way
if ( $mystring == "" )
{
      print $mystring; #will never print
}

The Right Way

$mystring = "";
$mystring2 = "foo";

if( $mystring eq "" )
{
      print $mystring; #will print
}

#the 'not equals' counterpart
if ( $mystring2 ne "")
{
      print $mystring2; #will print
}

And a helpful link for good measure.