I’ve been working on a web app for a few months now. It’s a PHP and MySQL driven database app which relates objects between each other.
I’d like to add functionality so that someone could register to use it and set up a monthly subscription. When they log in the app would simply populate with data from their own database.
I’ve done some scouring online but I’m struggling to find a starting point for adding this sort of feature.
The app relies on half a dozen tables within a database. So I’m also not sure if creating an individual database per user is practical.
Creating a db per user is very rarely the way to go – it’s complicated and has very few benefits with lots of drawbacks (eg maintaining multiple simultaneous Db connections as most libraries only connect to a single Db). What you really need to do is create a
usertable and then tag various records with aUserId.When a user registers, create a new
Userrecord, then create their new entries in other tables all referencing that Id. (Actually, only the “root” of each relational object needs aUserIdeg If you haveOrderandOrderItemsonly theOrdertable needs aUserId)Without more detail, it’s impossible to help further.
Incidentally, the only time you should consider db-per-user is if each user requires unique tables (in which case your app would have to be very complex to actually use the data) or if there are security concerns re: storing data together (more likely with multiple clients than multiple users).