I am creating an application where there is main DB and where other data is stored in secondary databases. The secondary databases follow a "plugin" approach. I use SQL Server.
A simple installation of the application will just have the mainDB, while as an option one can activate more "plug-ins" and for every plug-in there will be a new database.
Now why I made this choice is because I have to work with an exisiting legacy system and this is the smartest thing I could figure to implement the plugin system.
MainDB and Plugins DB have exactly the same schema (basically Plugins DB have some "special content", some important data that one can use as a kind of template - think to a letter template for example - in the application). Plugin DBs are so used in readonly mode, they are "repository of content". The "smart" thing is that the main application can also be used by "plugin writers", they just write a DB inserting content, and by making a backup of the database they creaetd a potential plugin (this is why all DBs has the same schema).
Those plugins DB are downloaded from internet as there is a content upgrade available, every time the full PlugIn DB is destroyed and a new one with the same name is creaetd. This is for simplicity and even because the size of this DBs is generally small.
Now this works, anyway I would prefer to organize the DBs in a kind of Tree structure, so that I can force the PlugIn DBs to be "sub-DBs" of the main application DB.
As a workaround I am thinking of using naming rules, like:
ApplicationDB (for the main application DB)
ApplicationDB_PlugIn_N (for the N-th plugin DB)
When I search for plugin 1 I try to connect to ApplicationDB_PlugIn_1, if I don't find the DB i raise an error. This situation can happen for example if som DBA renamed ApplicationDB_Plugin_1.
So since those Plugin DBs are really dependant on ApplicationDB only I was trying to "do the subfolder trick".
Can anyone suggest a way to do this? Can you comment on this self-made plugin approach I decribed above?
ADDED INFO (AFTER STARTING THE BOUNTY):
In the MainDB I plan to store the connection info to all the plugin DBs. Basically it is the database name, since I deigned the sytem in a way that even if I use multiple sql server logins to access the MainDB, behind the scenes a single user (typically "sa" or another user with admin privileges).
So basically if I need to query multiple databases I will use the database name to distinguish between plugins, I don't need to explicitly create fileds called PluginID in the database tables.
So somehow it works like this, in the main DB I store the plugin DB names. So I know the name of the plugins, so if I want to query all the GUNS from all plugins i will do something like this:
select * from ApplicationDB_Plugin_1.dbo.weapons where weapon_type = 'gun'
union
select * from ApplicationDB_Plugin_2.dbo.weapons where weapon_type = 'gun'
union
select * from ApplicationDB_Plugin_3.dbo.weapons where weapon_type = 'gun'
so the "trick" is using the dbname to distinguish between plugins. Now this work, but it seems a little "dirty" to me. My question is "IS THERE A BETTER APPROACH YOU CAN ENVISION?"