views:

254

answers:

5

I have a database server with few main databases, and few dozens of small ones.

These small databases are kind of intermediary/staging databases for data import from various sources into main database. Data import is a daily task. They are all quite similar in structure as the implementation of these data imports are similar, so basically they have a configuration tables, which define mapping, conversions etc, and the data tables, which contain the results of the import.

Some time ago there have been only the handful of small ones, but now I have more then 20 of them will grow further with the number of supported data feeds.

I have just migrated all the server environment to SQL Server 2008, and having some time now for clean-up/refactoring, I am thinking to merge all of data-import databases into just one database, and use database schema to separate them.

Question-0: Any other ideas for the described situation?

Question-1: Shall I change from a separate database to a separate schema?

Question-2: !!!: Any tricky thing to be careful about in database schema implementation?


Edit-1: highlighted question-2 as the most 'unanswered' currently.

+5  A: 

In your instance, I would probably put merge the databases into one. I don't really see a reason to have them separated, and merging them will reduce the amount of work you have to do to support backups etc. If you were importing data from a data source once and then never using the staging tables again, I could see the reason to bring up separate databases to handle the data transformation. Since you use these tables on an ongoing basis, I would much rather keep them together so that I only have to go to one place to find the full end to end state of the production data and the data load states.

2008 is really good at handling database partitioning too, if the db gets too large, or you need to separate data for security reasons you get the benefit of having a single db with the advantages like having several smaller ones. You won't get that with multiple smaller dbs.

Kevin
+3  A: 

When we migrated we had a very similar situation and I ended up moving everything into one some-what large Importing database like you have hinted towards. We did not, however, separate them using schemas.

ajdams
thanks, I would need to separate using schemas, because many table/view/sp names are the same. you did not have this issue, did you?
van
No I didn't, it worked out just fine.
ajdams
+3  A: 

Because the database is the unit of referential integrity and backup, if you are bringing in large amounts of data for staging which does not need to be backed up on the same schedule, it might be easiest to keep it in a separate DB.

You can use a single DB with multiple file groups and different backups, but it will require a lot more design.

The basic factors this will depend on are: recovery model, backup objectives, usage patterns and amount of effort to design and maintain your file group design.

Cade Roux
good point. most of them are really small, but there are few special ones which are more heavy - would make sense to keep them separately in any case.
van
+2  A: 

All the prior answers work for me, particularly your comment about selectively combining databases -- if some are very busy, very large, or process sensitive data, you might want to keep them separate, or in separate groupings. This would make it easier to configure backups/restores and disk/drive allocation (give the busy ones their own set of spindles).

Like possibly most database developers, I have dealt almost exclusively with objects in the dbo schema, but I have done some recent work with other schemas. The main gotcha I've encountered is remembering to always specify the schema when referring to any database object. Never assume that any given connection will reference an object in the schema you want it to--always be clear and precise!

Philip Kelley
very good point. I guess if I do this, I will make sure that "dbo" is the default schema for the users (which it is by default), but that "dbo" schema does not have db objects and/or users do not have much of permissions.
van
+1  A: 

I would put all your import staging tables in one database separate from your regular production databse as the backup needs may be very different. This database should also contains things like your configuration management for SSIS packages, any logging tables, any import metadata tables (we keep track of every run of the imports and the status of that run as well as a bazillion other things about the import like the filename, the normal file size, etc. Comes in handy for researching problems and for adding checks to the processing. We usea a schema that is by client and then an additional schema for objects realted to the importing/exporting process (logs, meta data etc.)

HLGEM