I want to know whether my approach is incorrect here
I have a simple website which you can register for. It has a main database called USERS which has a table with a list of all the users, and then for every new user a new database is generated called DB1,DB2,...,DBn. The reason I did this is because there is a lot of information being stored per user and I thought this would be a better approach. However, now I am running into the problem that the user databases need access to the table in the USERS database (for a foreign key) and I can’t figure out how to do that.
I admit that I don’t have much experience with MySQL, so it might be a very bad decision making a new database for every user. Is this the case? How efficient is MySQL? Can I, for example, create a list for (hypothetically) 100,000 users where each user has a further 100 entries for, lets say pictures, they have uploaded.
Thanks
This is an extremely bad design decision. What you want to do is create a single database for all of your tables in this application. In your example, you would have one database (call it
MyProject). You would have a users table, call itUser, that has all of your User entries in it–100,000 entries is a small database for modern hardware, so don’t worry about it. Then you’ll have a table calledUserPhotowhich contains a reference to the primary key inUseras well as whatever other data you need.