Is there a way to create subdatabases as a kind of subfolders in sql server?
Posted
by user193655
on Stack Overflow
See other posts from Stack Overflow
or by user193655
Published on 2010-05-20T10:24:06Z
Indexed on
2010/05/20
11:00 UTC
Read the original article
Hit count: 180
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?
© Stack Overflow or respective owner