I have made a site where the files' name will be stored as MD5
hash.
If I'm not wrong then a collision is bound to occur after 2^128 times, ignoring the repetitions. I have found a thread on this here and I'm satisfied with the probability of collision. It's almost 0.
However, I thought instead of using 32(+1) byte, declaring the column in the DB table as VARCHAR(32)
, I can use as 8(+1) byte for the name to save space. The probability of collision is 1/2^32, ignoring the repetitions.
To test this I altered the column to VARCHAR(8)
, keeping all the records same, about 260 entries, and checked the DB size but there was no change in the size of DB.
The formula I'm using is :
$temp = mysql_query("SHOW TABLE STATUS");
$size = 0;
while($row = mysql_fetch_array($temp)) {
$size += $row["Data_length"] + $row["Index_length"];
}
Got help from here.
Even I tried with FOREIGN KEY
reference in other tables where the files' names are being used but the size remained same as that of a table where I copied the full file name.
Now my question is where am I going wrong? Is it in the calculation of the DB size or in determining the size of the datatype of the column?
I'm not from a computer background and this is the first time I'm making a site so some points may sound silly to many. Sorry for that.