Home > Mobile >  Dedicated MySql table for each user
Dedicated MySql table for each user

Time:10-11

I'm a (self-taught) solo-developer trying to build my first full stack app. I can't really find much information about the topic, maybe I`m following the wrong path:

What I`ve achieved:

  • I created a CRUD app, with one MySql "user" linked table;
  • I created a login/registration system with dedicated "login" MySql table which once the user is logged in will redirect the user to the CRUD app page linked to the MySQL table and let the user perform all the CRUD operations;

What I want to achieve:

  • Every user has their own user table;

At the moment once the users are registered and logged in they can access to a only one common CRUD user table. So any user can modify the common CRUD user table. But what I want is that each user has his private CRUD user table.

The stack of the app is:SCSS; Node.js;Express.js;Handlebars;MySql

I willing to learn any other tool to go ahead with the app. Thanks for any roadmap/suggestions!

CodePudding user response:

  1. You can implement data restriction using sessions.
  2. For each user to have a private CRUD table, you can implement that by writing SQL query to create a table for each user on registration.

CodePudding user response:

If you must use this table-per-user application design, you will do the following:

  1. create the user's table at the time each new user registers on your app. You can name the table using the user's autoincrementing id in the shared table containing the users.
  2. when a user logs into your site, you'll use that same table name in your code when you create the various SQL statements to drive your app.

But, this application design does not scale up well. MySql does ok with hundreds of tables on a single server, but not with thousands or tens of thousands. That's because each concurrently open table takes significant RAM, CPU, and IO resources. All those resources are expensive and limited. Please, consider an alternative design with shared tables with useridcolumns.

  • Related