What is a good approach to preloading data?

Posted by Bob Horn on Stack Overflow See other posts from Stack Overflow or by Bob Horn
Published on 2010-06-11T16:12:56Z Indexed on 2010/06/11 16:22 UTC
Read the original article Hit count: 239

Filed under:
|
|
|

Are there best practices out there for loading data into a database, to be used with a new installation of an application? For example, for application foo to run, it needs some basic data before it can even be started. I've used a couple options in the past:

TSQL for every row that needs to be preloaded:

IF NOT EXISTS (SELECT * FROM Master.Site WHERE Name = @SiteName)
INSERT INTO [Master].[Site] ([EnterpriseID], [Name], [LastModifiedTime], [LastModifiedUser])
VALUES (@EnterpriseId, @SiteName, GETDATE(), @LastModifiedUser)

Another option is a spreadsheet. Each tab represents a table, and data is entered into the spreadsheet as we realize we need it. Then, a program can read this spreadsheet and populate the DB.

There are complicating factors, including the relationships between tables. So, it's not as simple as loading tables by themselves. For example, if we create Security.Member rows, then we want to add those members to Security.Role, we need a way of maintaining that relationship.

Another factor is that not all databases will be missing this data. Some locations will already have most of the data, and others (that may be new locations around the world), will start from scratch.

Any ideas are appreciated.

© Stack Overflow or respective owner

Related posts about database

Related posts about web-applications