Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does every user have their own database table?

For most major sites that you can preform CRUD operations does each user have their own database table? I would love to see an example of a database structure which multiple users, I'm looking at my wordpress database structure and just can't picture how twitter, tumblr, or even stackoverflow actually runs a database. Is it that easy to create a table for a user dynamically? Thanks in advance.

like image 437
ThomasReggi Avatar asked Aug 01 '10 04:08

ThomasReggi


People also ask

Why would each user have their own table?

Why would each user have their own table? A user should simply be an entry in a table. You then use the id of that user to look up other records in other tables. If you database contained sy 6 tables then each time you added a user youd also have to add the other tables again too.

How many tables can be created per user in a database?

You can create one table per user, but then you have to have a mapping of which user connects to which database, and you need to always open new connections to databases for each user. Show activity on this post. There are multiple different types of databases, but typically not.

Can a table have its own ID?

The table is a stand alone island so an ID would never be used in a join. All filters will be on the natural key. The ID would just waste space. No benefit from clustering on the ID, no benefit from the surrogate. Mapping or junction tables should never have their own ID. These are used to implement many-to-many relationships.

How do I identify a user in a table?

Then you have a couple of tables, say, blog_posts and comments. Each of these table contains blog posts and comments from all users. To identify a user, there is a "user_id" field which identifies a row in that table as belonging to a particular user.


1 Answers

Why would each user have their own table? A user should simply be an entry in a table. You then use the id of that user to look up other records in other tables.

If you database contained sy 6 tables then each time you added a user youd also have to add the other tables again too.

so now you have 10 users and 60 tables.

like image 142
griegs Avatar answered Sep 20 '22 19:09

griegs



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!