Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter name length in DB

I'm adding a field to a member table for twitter names for members on a site. From what I can work out the maximum twitter name length is 20 so it seems obvious that I should set the field size to varchar(20) (SQL Server).

Is this a good idea?

What if Twitter starts allowing multi-byte characters in the user names? Should I make this field nvarchar?

What if Twitter decides to increase the size of a username? Should I make it 50 instead and then warn a user if they enter a name longer than 20?

I'm trying to code defensively so that I can reduce the chances of modifying the code around this input field and the DB schema changes that might be needed.

like image 234
Guy Avatar asked Aug 26 '09 15:08

Guy


1 Answers

while looking for the same info i found the following in a sort of weird place in the twitter help section (why not in the API docs? who knows?):

"Your user name can contain up to 15 characters. Why no more? Because we append your user name to your 140 characters on outgoing SMS updates and IM messages. If your name is longer than 15 characters, your message would be too long to send in a single text message."

http://help.twitter.com/entries/14609-how-to-change-your-username

so perhaps one could even get away with varchar(16)

like image 124
jsh Avatar answered Sep 30 '22 02:09

jsh