Click here to Skip to main content
15,920,217 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi developers,


I would like to create a webApp with a general domain ex. mainApp.com
and multiple subdomains for each client ex. sub1.mainApp.com, sub2.mainApp.com etc.

What is the best way to bind each subdomain with the MySql.

I am thinking to create a unique id for each subdomain.

For example:

1. track the subdomain.
2. generate a unique id for the database ex. select * from "table" where client_id = "1231". (subdomain)

Is this the correct way;

What I have tried:

I am in process for the the DB design
Posted
Updated 13-Nov-21 21:40pm

1 solution

This highly depends on the data and the regulations you need to comply with. For example in some cases it's not enough to separate the data only by some id in a single database. In order to keep the data complete separate you may need to utilize completely separate databases.

In other scenarios a single database may be sufficient but you may need to create row level security one way or another. Also note that depending on the situation, it may not be enough to separate the data from the user point of view, you may also need to separate the data from admin/developer point of view.

If single database would be sufficient I'd recommend getting familiar with views and stored procedures which are basic tools to achieve row level permissions. Also pay close attention to the native permission management MySql has to offer to ensure that permissions are controlled reliably.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900