Archive for: August, 2008

Loops

Aug 26 2008 Published by under General

Try watching TV in a room where people are talking.

People want others to hear, so they talk loudly.
You increase the volume so that you can hear the TV.
People start talking louder…
You increase the volume further up…

Noise.
Nobody wins.

The same stuff happens when you try to listen to music at a place where people want to talk. You can see the same effect coming to play in many other places.

You advertise your product. Customers ignore your ads.
You increase the amount of your advertisements… Customers ignore them more.

People demand some features in your product. You add those features.
People demand more features in your product… You keep adding them.

Wise decisions can help you break loops like these.

5 responses so far

Choosing the length of your database password

Aug 26 2008 Published by under Programming, Security

Your choice of passwords shows how important the data secured by the password is. If the password for your email account is passw0rd, it means that the data in your email is not important enough (or that you don’t care much about the importance of the data). We all know that it is generally not a good idea to store user passwords in your database in the form of plain text. But in certain cases, you may be compelled to store user passwords directly in the plain text form in the database.

This means that all the user passwords are secured by a single database password. If someone brute forces the database password, he/she can read all the user passwords, and users as we know, are infamous for using the same passwords for most of their accounts everywhere. Thus the attacker can access other accounts of the user elsewhere.

As a developer/ DBA, it is your job to secure the data in your database. One thing you can do is to make the brute forcing of the database password as hard as brute forcing all the passwords in the database. This can be done by choosing the length of your database password wisely.

What should be the length of your database password?

Minimum length of database password = Average length of user passwords contained in the db *  log2 (number of user passwords) / 8

For example, if you are storing 1024 passwords of average length 8 characters, your database password should be at least 10 characters in length.

6 responses so far

Thank you clicks don't count

Aug 25 2008 Published by under Internet

Seth Godin says in his post this Friday:

If you like what you’re reading, click an ad to say thanks.

Pretty simple, but not an accepted online protocol, at least not yet.

If every time you read a blog post or bit of online content you enjoyed you clicked on an ad to say thanks, the economics of the web would change immediately. You don’t have to buy anything (though it’s fine if you do). You just have to honor the writer by giving them a click.

The idea is good, except that it won’t work.

There is an economy behind ads. If the value of a click decreases (it decreases when you click for giving a thank you), the click generates less revenue for the advertiser, and in turn the publisher is paid less. This means that the revenue of the publisher remains the same if you click genuinely or otherwise.

You can cheat for some days (may be), but then the numbers adjust themselves.

2 responses so far

The pigeonhole principle

Aug 23 2008 Published by under General

What is the pigeonhole principle?

The pigeonhole principle states that, given two natural numbers n and m with n > m, if n items are put into m pigeonholes, then at least one pigeonhole must contain more than one item.

I was thinking like: why pigeons? Who made up this thing?

Pigeon-hole

This is a photograph I took near Charminar, Hyderabad.

Look how the pigeons are sitting in such a disciplined way!!!

Now I know why the pigeonhole principle chose pigeons for illustrating the principle.

Here are some more interesting facts about the pigeonhole principle:

Although the pigeonhole principle may seem to be intuitive, it can be used to demonstrate possibly unexpected results. For example, there must be at least two people in London with the same number of hairs on their heads. A typical head of hair has around 150,000 hairs; it is reasonable to assume that no one has more than 1,000,000 hairs on his head (m = 1 million holes). There are more than 1,000,000 people in London (n is bigger than 1 million objects). If we assign a pigeonhole for each number of hairs on a head, and assign people to the pigeonhole with their number of hairs on it, there must be at least two people with the same number of hairs on their heads.

Uses and applications

The pigeonhole principle often arises in computer science. For example, collisions are inevitable in a hash table because the number of possible keys exceeds the number of indices in the array. No hashing algorithm, no matter how clever, can avoid these collisions. This principle also proves that any lossless compression algorithm that makes at least one input file smaller will make some other input file larger. (Otherwise, two files would be compressed to the same smaller file and restoring them would be ambiguous.)

Forgive me for the big quote. I thought you might be interested.

12 responses so far

Are foreign keys really necessary in a database design?

Aug 22 2008 Published by under Programming

Recently I asked a question in StackOverFlow:

Are foreign keys really necessary in a database design?

As far as I know, foreign keys are used to aid the programmer to manipulate data in the correct way. Suppose a programmer is actually doing this in the right manner already, then do we really need the concept of foreign keys?

Are there any other uses for foreign keys? Am I missing something here?

Many people responded and there were all kinds of opinions. The strange thing I noticed was that many people including Joel Spolsky do not use foreign key constraints in their databases.

You can build a complete application without even using a single foreign key constraint. Foreign keys, as a matter of fact are not essential in your databases, but they help a lot in programming and making robust systems. Hence the use of foreign key integrity constraints is strongly recommended.

These are the obvious advantages of using foreign key constraints:

  1. They help in keeping data integrity by removing the possibility of unwanted data piling up and cluttering the database. Mostly this data will not affect your business logic, but eventually you will have to take up the task of cleaning up the mess manually.
  2. They help in visualizing and preparing database diagrams. Many tools are available which will automate this task.
  3. They may give performance benefits. In systems which auto index fields, foreign key references can give a performance boost.
  4. Foreign keys can also help the programmer write less code using things like ON DELETE CASCADE and other referential actions.

If you know of any other advantages please add them below.

Curtis Poe has written a very good article about this mentioning the fundamental flaw in the thought against foreign keys:

If you have an SQL statement inserting data, you want the receiving table to have the data validation in the form of foreign keys, custom data types, enums, triggers and so on. If you’re writing code for personal use or you control an open-source project, skip this if you want. It’s your code; it’s your choice. However, if you’re writing code for a business, you don’t know who will be maintaining it tomorrow. Maybe they don’t know about your clever data validation routines which allow you to forego foreign keys. Maybe they’re finding your code too slow so they decide to write directly to the database themselves. Whatever the reason, by putting the data validation as close as possible to the data munging, you make it harder to circumvent.

In effect, foreign key constraints are a way of implementing a set of guidelines for proper querying and manipulation of data in a database. You can do away with them, but you are bound to make mistakes eventually without them.

42 responses so far

Voidy now in beta

Aug 21 2008 Published by under General, Internet

Voidy is in beta now.

The basic chatting functionality is working fine.

The good news is that 50+ of my friends are already using it and giving feedback.

The bad news is that since I have not done any PR stunt and since voidy is not featured in any of the techcrunch like sites, I don’t expect many users to know about it and use it. But that is fine; I primarily developed this for a very small group of people who wanted this exact functionality.

Thank you all for your support. If you have’nt registered already, sign-up and help me test the application.

4 responses so far

Why didn't that idea occur to me?

Aug 20 2008 Published by under General

Because you never deserved it…

What did you do with the hundreds of ideas which did occur to you?

3 responses so far

Older posts »