This is an interesting approach, but you probably want to store the "backwards" and "forwards" lookups in different databases, since 1) you don't double-write when a user specifies a key, and 2) you don't want to accidentally redirect to a short name when given a long url.