I am currently attempting to create a chat program aimed for 1000-1500 users. I was wondering if i should create a separate table for each user, as in a table for each users friends, message or should just create one include all table and store everything there, as in which solution would be more efficient? I believe having multiple tables for each users personal details would be more efficient so that most queries i run are run on tables with small amount of data.
Could anyone tell me if i am wrong?
You are very wrong. Ideal way should be to have one single table for users. Even for companies like ebay where there are millions of users; the way those users are distributed are like all users starting with A in a single table … As @Matt mentioned we cannot create tables where x is not a bounded number.
Along with that table you can have a table Messages which will have a column UserName which will be a foreign key pointing to your user table.
Cleanest possible solution can be a bit tricky for maintaining friends list. A workaround solution can be to have a column in User table which will have comma separated ids of Friends ( which are again users in same table ). If you do not want any limits on friends list: You could just create another table Friends having two columns userid, friendId. Both these columns will be foreign keys on User table. Now, query will be simple
select * form Friends where userid=<user>. This table might be huge; but that is where index comes into picture. You can create an index on userid column and query results will be super fast even with lots of records.