Reputation: 4769
I am structuring the config settings of a database, abstracting as far as possible the config data.
In the most common LAMP environments, connecting to a database requires the following four information:
I would like to understand two things:
If user and password are related to the host, they could access all the databases available on that host, so I could represent the config data this way (no matter it is an array, an object or other):
db_config
└─db_host
├─db_user
├─db_password
└─databases
├─db_name
└─db_engine
If user and password are instead related to a specific database, they could access the only db_name
specified; in this case I could schematize this way the config data:
db_config
└─db_host
└─databases
└─db_name
├─db_engine
├─db_user
└─db_password
Databases may be powered by different engines (e.g. PostgreSQL, MySQL, MSSQL, Oracle, Firebird, etc).
If credentials are related to the host, and if database with different engines may cohexist on the same host, the config data could be represented this way:
db_config
└─db_host
├─db_user
├─db_password
└─databases
└─db_name
└─db_engine
But this structure does not allow databases with different engines to have the same name.
Can databases with different engines cohexist on the same host and use the same name?
If yes, the config data could be structured so:
db_config
└─db_host
└─db_engine
└─databases
├─db_name
├─db_user
└─db_password
What data structure fits most possible real situations?
Upvotes: 0
Views: 72
Reputation: 48246
It's kinda complicated, as different vendors have different features.
First, User/Password credentials should stand on their own. They might apply to a particular database server, but could be used for multiple databases too, or some other software. They are basically orthogonal.
Some databases support Active Directory/LDAP/Kerberos, SSL Certificates, PAM etc for login, not just username/passwords.
Some other points:
In PostgreSQL at least, the users are children of the cluster, and not of a particular database, except I recall an obscure setting that lets you change this...
Upvotes: 1