Just my 2 cents worth.
A bolt is as strong as it's weakest point, if a bolt has a diameter of 8mm it is of no use having it threaded in a hole that is 30mm deep when the weakest point is the 8mm diameter. There is also the strength of the thread to take into consideration, if you have a weak thread you need a longer threaded portion to hold the bolt.
A basic rule I have always used, is a thread in alloy should be double the diameter of the bolt to be secure. A thread in steal should roughly be 1.5 times the diameter of the bolt.