Archive for December 7th, 2007

Top 10 Reasons for NOT backing up your data

In this modern age we live in, who has time to backup their data? It’s such a hassle! Not to mention it’s really complicated and expensive. I was thinking about backups the other day and there’s practically *no reason* to do it! In fact, I came up with 10 reasons not to make backups. I think if you take a moment to read them you’ll agree with me that backups are simply a waste of time.

1. I just got a new computer, it’s not going to break

We all know that new stuff *never* breaks. Come on! Things only break after years and years. I’ve never purchased one single item that I had to return right away because it didn’t work correctly.

2. I’m really nice to my computer. People who lose their data probably are hitting their computer or something.

People who lose their data are obviously physically harming their computer in some way. They just don’t admit it because they’re embarrassed. Me, on the other hand, I am very gentle with my computer. I even give it a goodnight kiss before bed every evening.

3. Oh, I’m going to back up my files as soon as I get a chance…

I was planning on backing up my files last month but I got so busy, you know. I just didn’t get around to it. I’ll get to it pretty soon, though.

4. Hard drives start clicking before they crash – I’m confident I’ll be able to tell when it’s about to go.

Everybody knows that hard drives don’t just die instantly. They start clicking and making weird noises weeks before they crash. There’s plenty of warning. Besides, if it does crash, I’ll just stick it in the freezer and that’ll give me a few hours to get my data back.

5. My data isn’t really that important, I wouldn’t be too upset if it got lost.

I really wouldn’t miss any of my data if it got deleted. I have a lot of digital photos of vacations and my favorite niece when she was a baby and about 200 albums in iTunes or whatever. But, I don’t really need that stuff. It’s not like my quicken bank file, job resume or my thesis or anything important is on there.

6. Making backups is too technical and complicated to do correctly.

Making backups is so technical. You have to have giant tape machines and take them to a a bank vault and all of that stuff to do it properly. I can’t deal with that! Making a copy to an external drive is not really the right way to do it, so why even bother?
7. Backups are something that big companies do. Home users don’t need to worry about backups.

They backup stuff at work so I don’t really have to backup my own machine as well. I probably have some of my stuff on floppy drives somewhere anyway.

8. I don’t have anywhere to store my backup data.

If there were some free magical place where I could backup my files I might do it. I don’t really have any storage space to spare because my external drive is all filled up and I can’t really afford another one.

9. I don’t have time to wait around for my stuff to back up.

It takes forever to backup files. I don’t have time to sita around and wait on that. It makes me uncomfortable to have my computer doing stuff while I’m not watching it.

10. I could always just call a data recovery service to get the stuff off of my drive – it’s never totally gone.

Those recovery guys can get anything back off of your drive even if you dip it in gasoline and light it on fire! It’s not like somebody would ever steal my laptop or something. I’m totally rich, though, so I can afford it either way.

~~~

There you have it. Ten compelling reasons not to backup your files. Are you convinced? Leave me a comment and let me know how you feel about it.

Subtracting unsigned integers with MySQL

Unsigned integer values are used in a database when you only expect to contain positive values and no negative values (less than zero). If you know a certain field will never legitimately contain negative values, then this is actually the most efficient field type to select.

There is a catch with unsigned ints however that can create problems for you if you’re not careful. That is, when you subtract unsigned ints, you will always get a positive value back no matter what. What does that mean?

Say you have a table for products with two unsigned fields: qty_in_stock and qty_sold. Lets assume for whatever reason you oversold your inventory and qty_in_stock now equals 100, but qty_sold = 101. So take the following statement:

SELECT qty_in_stock - qty_sold AS qty_remaining FROM products

You would expect qty_remaining to be -1, right? Wrong! In fact MySQL returns 18446744073709551615 !

Why would this happen? Well, because MySQL is built so that when you perform a math operation on two unsigned ints, it will always return an unsigned int. And -1 is technically an out-of-bounds value for an unsigned field type. Instead of complaining, MySQL returns the value that would have represented -1 if it were unsigned which is 18446744073709551615.

Mathematically, I suppose this is correct, however it doesn’t make any logical sense to me. If anything, I think MySQL should throw an out-of-bounds error when this happens because the default behavior seems very unintuitive to me. It is as though they are trying to say that one positive value subtracted from another can never result in a negative value. Of course this is false, but that is how MySQL works.

There are two solutions to this. The first is to simply use signed ints if you ever expect them to be used in a subtraction formula. You waste some space, but it’s an easy fix.

The second solution is, if you are able to edit your SQL statement that have the subtraction, you can use the MySQL cast function. The example from above could be converted to the following:

SELECT cast(qty_in_stock - qty_sold AS signed) AS qty_remaining FROM products

So there is a solution to this “problem” if you will. You can read more about this subject on the MySQL site at http://dev.mysql.com/doc/refman/4.1/en/cast-functions.html

Return top