Creating a New Database Schema

 

Follow the instructions in this section to create a new database schema using the Connectivity Kit.

The Microsoft SQL Server database build procedures are intended for the database administrator to build the Inspect database schema on the database server.

Specific database build procedures vary, depending on the tools used by the database administrator. This documentation provides only general procedures.

The following list outlines the required steps for the update:

1.     Copy the build script files to the database server.

2.     Edit the required files.

3.     Execute the InspectBuild.cmd script.

4.     Verify the build process.

5.     Update to the latest database schema.

Step 1: Copy the Contents of the Build Directory

In order to build the database the required files must be on the machine holding the database server. If Inspect has not been installed on the database server machine the files must be copied to it.

After installing the Connectivity Kit the build files can be found, by default, in the following directory:

C:\Program Files\Applied Tech Systems\Inspect\Connectivity Kit\Build

Copy this directory to the database server before beginning the following procedures.

Step 2: Edit files

InspectBuild.cmd

Use a text editor such as Notepad to edit the InspectBuild.cmd script, the main command file that calls the other SQL files to build the database. The InspectBuild.cmd file contains the following default values:

       Server: localhost

       User name: sa

       System Administrator (sa) Password: master

       Database Name: INSPECT

Modify them as required. They will be shown as follows:

sqlcmd -S localhost -U sa -P master -d inspect -iCreateRoles.sql -o logs\CreateRoles.out

The InspectBuild.cmd file executes several files using the Microsoft SQL Server OSQL utility.

Modify the following two files as required:

01 - CreateDatabase.sql

The database name is shown twice. Be sure to modify both of them:

create database <database_name>...

alter database <database_name> ...

By default, the CreateDatabase.sql file creates the empty database schema and contains the following default values from the InspectBuild.cmd file:

11 - ChangeDatabaseOwner.sql

Sets the database owner to Inspect. Change this file to change the database owner to a different login.

Other files

InspectBuild.cmd also runs the contents of the following files.

DO NOT make modifications to these files:

Filename Description
02 - CreateRoles.sql

Creates a new 'db_executor' role which allows execute permissions for all stored procedures.

03 - CreateDatabaseUsers.sql

Creates two logins and database users.

04 - CreateBasicSchema.sql

Creates all database tables and related objects like constraints, foreign keys, indexes, etc.

05 - CreateSequenceTables.sql

 

06 - CreateFunctions.sql

Creates all Inspect database functions.

07 - CreateStoredProcedures.sql

Creates all Inspect database stored procedures.

08 - CreateTriggers.sql

Creates all Inspect database triggers.

09 - CreateLookupValues.sql

Loads lookup data into the database.

10 - CreateApplicationUsers.sql

Creates two 'default' application users and gives them super user privileges. The user names and passwords match the SQL Server logins created by the CreateLoginsAndUsers.sql script.

12 - DatabaseVerify.sql

Verifies the database creation by checking the counts of all major objects in the database.

Step 3: Execute the Database Build Script

Execute the script by typing InspectBuild.cmd at the command prompt on the server.

The InspectBuild.cmd script does the following:

       Creates a subdirectory \logs. If a \logs directory exists, it deletes all old *.err and *.out files from the logs subdirectory.

       Retrieves the version number of the database and the time from the database.

       Creates all database objects like Tables, Triggers, Stored Procedures, Indexes, Foreign Keys, etc.

       Inserts default data and manages permission on all tables.

       Runs the database verification script.

Step 4: Verify the Build Process

1.     Change the directory to the logs directory and make sure that there are no *.err files.

2.     Compare the counts in the DatabaseVerify.out file and make sure they match (each count should be duplicated).

3.     If the counts value does not match, then review the *.out file(s) and execute the appropriate step(s) to resolve the issue(s).

Step 5: Update to latest Schema

Now that the database has been created it must be updated to the latest schema.

For information on how to do this see here.

Using the Database

Two standard logins are created for a new database, as follows:

Username: inspect

Password: Quality2010

 

Username: ekutay

Password: Quality2010