Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can i create each table for each user in my social networking site?

I'm creating a social networking site with features similar to Facebook. I want to start with schema design for my database. What i thought was to create each table for each user who registers to our site.. am i doing right?

If a million users register to my site, a million tables will be created. how to go on about optimizing this? Please do suggest me techniques to overcome this and some references or books to learn about such concepts will be vry useful..

Thanks in Advance.

like image 295
Noddy Cha Avatar asked Jan 20 '23 14:01

Noddy Cha


2 Answers

This is not the way you want to do it.

What you want to do is have a table (perhaps called 'users') that contains one row for each user that registers. Creating a new table for each user is completely pointless and would cause terrible performance.

Maybe something like this:

 TABLE users
   - username AS VARCHAR(255)
   - password AS VARCHAR(255) (use a hashed password, of course)
   - ...

Then when a user registers, simply insert the information they provide into the users table as a new row.

like image 86
Nathan Osman Avatar answered Jan 23 '23 04:01

Nathan Osman


That would be massive overkill. You should probably read up on database design (start with normalisation, but don't overdo it). Then write down what you want to save for each user, and think about how to save it without saving data double.

But I'm pretty sure a table-per-user is not an option for this.

like image 30
Nanne Avatar answered Jan 23 '23 03:01

Nanne