Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should one create a new table for each user on a web app?

I'm writing my first web app, and I know enough about databases to know that the schema is important but not enough to know how to actually write a good one.

Is there a standard protocol for handling information stored in each user account? My instinct is to have one table that stores the user's key and log-in info, and a handle to their table (probably the key?), and then have one table for each user.

But I wonder if there are performance issues around having table for each user or if that seems an incredibly stupid way to do it. This seems like it should be a "solved problem" since basically all web apps have user accounts, but I haven't been able to find anything via search. Are there any resources with "solved" schemas for storing various sorts of web data?

like image 998
araneae Avatar asked Dec 11 '10 19:12

araneae


1 Answers

Usually you would not create a separate table for each user - this solution does not scale well.

Instead you usually put all users' data into a single table (or one table per type of data) and use conditions in the WHERE clause to ensure that a user can only read/write their own data.

like image 119
Mark Byers Avatar answered Oct 08 '22 05:10

Mark Byers