Youtube seems to have a unique 11 digit code for each video. the code includes 1-9,A-Z,a-z
, and some symbols like +_*
etc.
How would they calculate this unique code for each video? I am working on something where I'd like to assign a unique code to each record so hence the question.
My questions/concerns are:
- If they make it on-the-fly (when videos are submitted) then they'd have to check whether the code prepared for the video already exists or not? That would be an expensive operation across huge dataset like theirs.
- Would they run a batch job sort of thing every night or every month that creates unique codes and stash them in the DB. Then as the video is submitted it just takes a code and marks it off as "used"
- Would it make sense to take the auto-generated and auto-incremented
ID
column for each record in the DB and then somehow convert that uniqueID
column to an 11 digit code?
My goal is to:
- create a unique code for a record in the table.
- The user can share the url with that unique code with anyone.
- When someone comes in via the unique code. Then their "coming in" gets tied to the original user who shared the url with unique code.