1

From my experience I have used proxy servers to refer to different servers (nginx).

I have previously worked on building a mvc framework. Basically there were 8 databases with 10 accounts each. The main database had the server addresses and db credentials for each of the other databases. Whenever a user logged in, the main db will disconnect and connect to the appropriate user database.

I was wondering if there in a more common way to do that other than hard-coding this to the database class(s).

I have been thinking about proxy servers that basically refer a user to servers. So maybe it's possible to do the same but for db servers? (Just a thought..)

2
  • #1 is the database switch handled with a programming language or at database level? #2 How do you handle the database connection pool? #3 What is the goal of that strategy? Hide the real ip/user/password of database instances?
    – JRichardsz
    Jul 26 at 14:24
  • #1 with the programing language. if user credentials are verified I disconnect from the main db and connect to the right user db #2 fetch user credential inputs and validate them within the main database, if they match: get the user logged in by disconnecting from the main db and connecting to the user db where all his/her data exist. user db credentials are in the main db. #3 yes. This project belonged to an over 10 years company with really old code. i don't believe there is a strategy behind this. I just want to understand what is the common "modern" way to navigate between db. @JRichardsz
    – Kar19
    Jul 26 at 21:13
2

The most usual strategy is a direct connection from application (java, php, c#, python, ruby, etc) to the database (mysql, oracle, sql server, postgres, mongo, etc)

In your development stage, your app and database are in your laptop. In this scenario is not common to apply security regulations.

In the next stages like testing, staging, uat, production, etc the security should be applied:

  • Developers should not know the database credentials of another environments, especially production
  • Database credentials should not be in the source code. The application should use configurations files or environment variables.
  • Database must be under ssl

With these security regulations or standards, you will not need crazy and unmaintainable database switch to protect your final database.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.