I am building a facebook application and the application accesses the user’s friends through the open graph and I need them contained in a database.
Now here this database contains the user id, name and some other info needed by my app. In order to prevent multiple entries in the database, I assigned the user id as unique using phpMyAdmin. now this works fine for many values but at the same time it fails big time.
Lets say the values that are unique according to mysql are:
51547XXXX
52160XXXX
52222XXXX
52297XXXX
52448XXXX
But if the ids become
5154716XX
5154716XX
or
5216069673X
521606903XX
Then it counts it as similar and thus discards one of them.
The result, lets say I am entering my friend list into the table, then it should have 830 records and if I do not use the unique constraint thats the value I get.
But as soon as unique is activated, I just get 375 which means 455 records are discarded, considering them same as the previous data..
The solution what I can think of is, comparing data with php first and then logging them into the database, but then with that much queries, it will take long long time. Google cannot answer this, dunno why.. 🙁
Facebook user ids are too big to fit into MySQL’s INT type (which is 32bit). You need to use the BIGINT type which is 64 bit and can thus handle the range of ids facebook uses.