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.
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With