I understood the process to shorten the URL with base 62 at How do I create a URL shortener?.
Steps given are
- Think of an alphabet we want to use. In your case, that's [a-zA-Z0-9]. It contains 62 letters.
- Take an auto-generated, unique numerical key (the auto-incremented id of a MySQL table for example).
- For this example, I will use 12510 (125 with a base of 10).
- Now you have to convert 12510 to X62 (base 62)
My question is why not just create unique numerical key and return it ? What is the advantage of concerting numerical key > Base 62 > then Finally some alphanumeric number ? Is it because final alphanumeric number will be much smaller than unique numerical key ?
Yes. The idea is to make it short and usable in a URL. A number in base 62 will use fewer characters than the same number in base 10. Notice also that URL shorteners use short hosts, such as g.co.