Database Reference
In-Depth Information
Figure 2-11. The data warehouse tables
These tables represent a very minimal design. As shown in Chapter 4, there are typically several dimension
tables in a data warehouse, not just one. For now, though, let's keep focusing on the big picture and come back to
the details later.
Using SQL Code to Create a Data Warehouse
One of the solution documents, InstWeatherTrackerDW.sql , has SQL code that creates the DWWeatherTracker
data warehouse for you when it is executed in SQL Server Management Studio. Before we have you execute this
code, let's review what it does.
Not The code file InstWeatherTrackerDW.sql can be found as one of the documents you added to your visual
Studio solution in Exercise 2-1. it opens within visual Studio if you double-click the file. in the next exercise, we open
and run the code in SQL Server Management Studio, so you will become used to working with both tools.
Create the Database
The first set of tasks that the SQL code tackles is checking to see whether the database already exists and, if
so, drop it. We labeled the first tasks Step 1 in our code (Listing 2-2). After that, in Step 2, the code creates the
database and tells SQL Server to use the new database for all the commands that come next.
Listing 2-2. Drop and Create the Database
--Step 1) Drop the database as needed
Use Master
Go
If ( exists( Select Name from SysDatabases Where name = 'DWWeatherTracker' ) )
Begin
Alter Database [DWWeatherTracker] Set single_user With rollback immediate
Drop Database [DWWeatherTracker]
End
 
 
Search WWH ::




Custom Search