Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Apress committed Oct 16, 2016
0 parents commit d4a8157
Show file tree
Hide file tree
Showing 1,420 changed files with 425,655 additions and 0 deletions.
Binary file added 9781430234883.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions LICENSE.txt
@@ -0,0 +1,27 @@
Freeware License, some rights reserved

Copyright (c) 2012 Randal Root and Caryn Mason

Permission is hereby granted, free of charge, to anyone obtaining a copy
of this software and associated documentation files (the "Software"),
to work with the Software within the limits of freeware distribution and fair use.
This includes the rights to use, copy, and modify the Software for personal use.
Users are also allowed and encouraged to submit corrections and modifications
to the Software for the benefit of other users.

It is not allowed to reuse, modify, or redistribute the Software for
commercial use in any way, or for a user�s educational materials such as books
or blog articles without prior permission from the copyright holder.

The above copyright notice and this permission notice need to be included
in all copies or substantial portions of the software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS OR APRESS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


15 changes: 15 additions & 0 deletions README.md
@@ -0,0 +1,15 @@
#Apress Source Code

This repository accompanies [*Pro SQL Server 2012 BI Solutions*](http://www.apress.com/9781430234883) by Randal Root and Caryn Mason (Apress, 2012).

![Cover image](9781430234883.jpg)

Download the files as a zip using the green button, or clone the repository to your machine using Git.

##Releases

Release v1.0 corresponds to the code in the published book, without corrections or updates.

##Contributions

See the file Contributing.md for more information on how you can contribute to this repository.
5 changes: 5 additions & 0 deletions _BookFiles/Chapter01Files/Chapter01_Listings.sql
@@ -0,0 +1,5 @@
/********** Pro SQL Server 2012 BI Solutions **********
This file contains the listing code found in chapter 1
*******************************************************/

-- There are no listing in this chapter.
Binary file added _BookFiles/Chapter01Files/ReadMe.doc
Binary file not shown.
71 changes: 71 additions & 0 deletions _BookFiles/Chapter02Files/Chapter02_Listings.sql
@@ -0,0 +1,71 @@
/********** Pro SQL Server 2012 BI Solutions **********
This file contains the listing code found in chapter 2
*******************************************************/

-- Listing 2-1. Sample ETL Code
-- Convert the a data string to datetime
Declare @Date Char(11)
Set @Date = '1/23/2011'
Select @Date; -- Outcome = 1/23/2011
Select Convert(datetime, @Date) -- Outcome = 2011-01-23 00:00:00.0
Go

-- 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
Go

-- Step 2) Create Data Warehouse Database
Create Database DWWeatherTracker
Go
Use DWWeatherTracker
Go


-- Listing 2-3. Creating three tables
-- Step 3) Create a Staging table to hold imported ETL data
CREATE TABLE [WeatherHistoryStaging]
( [Date] varchar(50)
, [Max TemperatureF] varchar(50)
, [Min TemperatureF] varchar(50)
, [Events] varchar(50)
)
Go

-- Step 4) Create Dimension Tables
Create Table [DimEvents]
( [EventKey] int not null Identity
, [EventName] varchar(50) not null
)
Go

-- Step 5) Create Fact Tables
Create Table [FactWeather]
( [Date] datetime not null
, [EventKey] int not null
, [MaxTempF] int not null
, [MinTempF] int not null
)
Go

-- Listing 2-4. Adding the primary keys
-- Step 6) Create Primary Keys on all tables
Alter Table DimEvents Add Constraint
PK_DimEvents primary key ( [EventKey] )
Go
Alter Table FactWeather Add Constraint
PK_FactWeathers primary key ( [Date], [EventKey] )
Go

-- Listing 2-5. Adding the foreign Foreign keysKeys
-- Step 7) Create Foreign Keys on all tables
Alter Table FactWeather Add Constraint
FK_FactWeather_DimEvents Foreign Key( [EventKey] )
References dbo.DimEvents ( [EventKey] )
Go
@@ -0,0 +1,53 @@
-- 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
Go

-- Step 2) Create Data Warehouse Database
Create Database DWWeatherTracker
Go
Use DWWeatherTracker
Go

-- Step 3) Create a Staging table to hold imported ETL data
CREATE TABLE [WeatherHistoryStaging]
( [Date] varchar(50)
, [Max TemperatureF] varchar(50)
, [Min TemperatureF] varchar(50)
, [Events] varchar(50)
)

-- Step 4) Create Dimension Tables
Create Table [DimEvents]
( [EventKey] int not null Identity
, [EventName] varchar(50) not null
)
Go

-- Step 5) Create Fact Tables
Create Table [FactWeather]
( [Date] datetime not null
, [EventKey] int not null
, [MaxTempF] int not null
, [MinTempF] int not null
)

-- Step 6) Create Primary Keys on all tables
Alter Table DimEvents Add Constraint
PK_DimEvents primary key ( [EventKey] )
Go
Alter Table FactWeather Add Constraint
PK_FactWeathers primary key ( [Date], [EventKey] )
Go

-- Step 7) Create Foreign Keys on all tables
Alter Table FactWeather Add Constraint
FK_FactWeather_DimEvents Foreign Key( [EventKey] )
References dbo.DimEvents ( [EventKey] )
Go

@@ -0,0 +1,28 @@

-- Convert the a data string to datetime
Declare @Date Char(11)
Set @Date = '1/23/2011'
Select @Date; -- Outcome = 1/23/2011
Select Convert(datetime, @Date) -- Outcome = 2011-01-23 00:00:00.0

-- Clear Tables
Delete From dbo.WeatherHistoryStaging
Delete From dbo.FactWeather
Delete From dbo.DimEvents

-- Get Dimension data from staging table
Select
[Events]
From dbo.WeatherHistoryStaging

-- Get Fact data from staging table
Select
[Date] = Convert(datetime, WHS.[Date])
, [Max TemperatureF]
, [Min TemperatureF]
, [EventKey]
From dbo.WeatherHistoryStaging as WHS
Join dbo.DimEvents as DE
On WHS.[Events] = DE.[EventName]


@@ -0,0 +1,6 @@
Date Max TemperatureF Min TemperatureF Events
1/23/2011 48 43 Rain
1/24/2011 51 46 Rain
1/25/2011 52 38 Rain/Sun
1/26/2011 53 41 Rain/Sun
1/27/2011 50 37 Fog
@@ -0,0 +1,164 @@
<Cube xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ddl2="http://schemas.microsoft.com/analysisservices/2003/engine/2" xmlns:ddl2_2="http://schemas.microsoft.com/analysisservices/2003/engine/2/2" xmlns:ddl100_100="http://schemas.microsoft.com/analysisservices/2008/engine/100/100" xmlns:ddl200="http://schemas.microsoft.com/analysisservices/2010/engine/200" xmlns:ddl200_200="http://schemas.microsoft.com/analysisservices/2010/engine/200/200" xmlns:ddl300="http://schemas.microsoft.com/analysisservices/2011/engine/300" xmlns:ddl300_300="http://schemas.microsoft.com/analysisservices/2011/engine/300/300" xmlns:dwd="http://schemas.microsoft.com/DataWarehouse/Designer/1.0" dwd:design-time-name="db3728a7-839a-451f-bfe0-b2fcfb1a9913" xmlns="http://schemas.microsoft.com/analysisservices/2003/engine">
<ID>DWWeatherTracker</ID>
<Name>DWWeatherTracker</Name>
<CreatedTimestamp>0001-01-01T00:00:00Z</CreatedTimestamp>
<LastSchemaUpdate>0001-01-01T00:00:00Z</LastSchemaUpdate>
<Annotations>
<Annotation>
<Name>http://schemas.microsoft.com/DataWarehouse/Designer/1.0:DiagramLayout</Name>
</Annotation>
<Annotation>
<Name>http://schemas.microsoft.com/DataWarehouse/Designer/1.0:ShowFriendlyNames</Name>
<Value>true</Value>
</Annotation>
<Annotation>
<Name>http://schemas.microsoft.com/DataWarehouse/Designer/1.0:ShowRelationshipNames</Name>
<Value>false</Value>
</Annotation>
<Annotation>
<Name>http://schemas.microsoft.com/DataWarehouse/Designer/1.0:UseDiagramDefaultLayout</Name>
<Value>true</Value>
</Annotation>
<Annotation>
<Name>http://schemas.microsoft.com/DataWarehouse/Designer/1.0:DiagramViewPortLeft</Name>
<Value>0</Value>
</Annotation>
<Annotation>
<Name>http://schemas.microsoft.com/DataWarehouse/Designer/1.0:DiagramViewPortTop</Name>
<Value>0</Value>
</Annotation>
<Annotation>
<Name>http://schemas.microsoft.com/DataWarehouse/Designer/1.0:DiagramBoundingLeft</Name>
<Value>0</Value>
</Annotation>
<Annotation>
<Name>http://schemas.microsoft.com/DataWarehouse/Designer/1.0:DiagramBoundingTop</Name>
<Value>0</Value>
</Annotation>
<Annotation>
<Name>http://schemas.microsoft.com/DataWarehouse/Designer/1.0:DiagramZoom</Name>
<Value>100</Value>
</Annotation>
</Annotations>
<LastProcessed>0001-01-01T00:00:00Z</LastProcessed>
<State>Unprocessed</State>
<Dimensions>
<Dimension dwd:design-time-name="7b580e55-800e-4c0e-8f9c-7a4f90472dcc">
<ID>DimDate</ID>
<Name>DimDate</Name>
<DimensionID>DimDate</DimensionID>
<Attributes>
<Attribute dwd:design-time-name="d57c2d1a-848d-443c-a1e0-ed44c797edec">
<AttributeID>EventDate</AttributeID>
</Attribute>
</Attributes>
</Dimension>
<Dimension dwd:design-time-name="47563a57-d682-4b97-8a54-7464ad94c80f">
<ID>DimEvents</ID>
<Name>DimEvents</Name>
<DimensionID>DimEvents</DimensionID>
<Attributes>
<Attribute dwd:design-time-name="b1d56c5c-1266-4a5b-a7d7-07712cdaeef5">
<AttributeID>Event</AttributeID>
</Attribute>
</Attributes>
</Dimension>
</Dimensions>
<MeasureGroups>
<MeasureGroup dwd:design-time-name="550b8f07-690e-407a-8657-6e2efe836b1e">
<ID>Fact Weather</ID>
<Name>Fact Weather</Name>
<CreatedTimestamp>0001-01-01T00:00:00Z</CreatedTimestamp>
<LastSchemaUpdate>0001-01-01T00:00:00Z</LastSchemaUpdate>
<LastProcessed>0001-01-01T00:00:00Z</LastProcessed>
<State>Unprocessed</State>
<Measures>
<Measure dwd:design-time-name="73071e7f-bb01-4715-8c63-d92026b75124">
<ID>Max Temp F</ID>
<Name>Max Temp F</Name>
<Source dwd:design-time-name="5398321d-9022-43bd-83d3-1999faf4afcb">
<DataType>Integer</DataType>
<Source xsi:type="ColumnBinding" dwd:design-time-name="51986057-5e2e-4926-b536-2562019b5f77">
<TableID>dbo_FactWeather</TableID>
<ColumnID>MaxTempF</ColumnID>
</Source>
</Source>
</Measure>
<Measure dwd:design-time-name="c5f3737a-d63d-4327-9a11-d628846c63c5">
<ID>Min Temp F</ID>
<Name>Min Temp F</Name>
<Source dwd:design-time-name="93a8aaa1-e488-408b-8fcc-02d816ab8fd2">
<DataType>Integer</DataType>
<Source xsi:type="ColumnBinding" dwd:design-time-name="56856de6-b5ba-4429-8d4a-47719af3288b">
<TableID>dbo_FactWeather</TableID>
<ColumnID>MinTempF</ColumnID>
</Source>
</Source>
</Measure>
<Measure dwd:design-time-name="449a16dd-454e-4a5b-820f-b46516416ba8">
<ID>Fact Weather Count</ID>
<Name>Fact Weather Count</Name>
<AggregateFunction>Count</AggregateFunction>
<Source dwd:design-time-name="7cbbf45f-7791-46a1-a123-16c826645011">
<DataType>Integer</DataType>
<DataSize>4</DataSize>
<Source xsi:type="RowBinding" dwd:design-time-name="8f924198-d8b2-4cdd-9da1-5dcd2f0751f1">
<TableID>dbo_FactWeather</TableID>
</Source>
</Source>
</Measure>
</Measures>
<StorageMode>Molap</StorageMode>
<ProcessingMode>Regular</ProcessingMode>
<Dimensions>
<Dimension xsi:type="DegenerateMeasureGroupDimension" dwd:design-time-name="e45e9714-bae0-4f63-b237-69a2eff2ceff">
<CubeDimensionID>DimDate</CubeDimensionID>
<Attributes>
<Attribute dwd:design-time-name="cd08815c-194e-43a5-8847-4d44b74ac585">
<AttributeID>EventDate</AttributeID>
<KeyColumns>
<KeyColumn dwd:design-time-name="4615cfa7-a0bb-4ba1-bcdb-0e79820a7efb">
<DataType>Date</DataType>
<Source xsi:type="ColumnBinding" dwd:design-time-name="c390a1ba-9b5c-4cf2-9fb0-74c37a4ecdbe">
<TableID>dbo_FactWeather</TableID>
<ColumnID>Date</ColumnID>
</Source>
</KeyColumn>
<KeyColumn dwd:design-time-name="1f221fda-962e-49e6-8cc1-8b28d9f41de5">
<DataType>Integer</DataType>
<Source xsi:type="ColumnBinding" dwd:design-time-name="9c7c5bc0-8402-4d73-a499-31aa1617be7f">
<TableID>dbo_FactWeather</TableID>
<ColumnID>EventKey</ColumnID>
</Source>
</KeyColumn>
</KeyColumns>
<Type>Granularity</Type>
</Attribute>
</Attributes>
</Dimension>
<Dimension xsi:type="RegularMeasureGroupDimension" dwd:design-time-name="01b1885b-836c-496c-a4fd-066fc5e7eb39">
<CubeDimensionID>DimEvents</CubeDimensionID>
<Attributes>
<Attribute dwd:design-time-name="809efcea-4749-4ed1-b3d2-de616c5fef7f">
<AttributeID>Event</AttributeID>
<KeyColumns>
<KeyColumn dwd:design-time-name="8cc3aa50-b20f-465d-9854-6f72b1d2e3c9">
<DataType>Integer</DataType>
<Source xsi:type="ColumnBinding" dwd:design-time-name="d0852b81-13d7-4c3d-8182-9304582f187c">
<TableID>dbo_FactWeather</TableID>
<ColumnID>EventKey</ColumnID>
</Source>
</KeyColumn>
</KeyColumns>
<Type>Granularity</Type>
</Attribute>
</Attributes>
</Dimension>
</Dimensions>
<Partitions />
</MeasureGroup>
</MeasureGroups>
<Source dwd:design-time-name="8e283a7b-32b9-474b-871b-32bda8fe5421">
<DataSourceViewID>DWWeatherTracker</DataSourceViewID>
</Source>
</Cube>
@@ -0,0 +1,14 @@
<DataSource xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ddl2="http://schemas.microsoft.com/analysisservices/2003/engine/2" xmlns:ddl2_2="http://schemas.microsoft.com/analysisservices/2003/engine/2/2" xmlns:ddl100_100="http://schemas.microsoft.com/analysisservices/2008/engine/100/100" xmlns:ddl200="http://schemas.microsoft.com/analysisservices/2010/engine/200" xmlns:ddl200_200="http://schemas.microsoft.com/analysisservices/2010/engine/200/200" xmlns:ddl300="http://schemas.microsoft.com/analysisservices/2011/engine/300" xmlns:ddl300_300="http://schemas.microsoft.com/analysisservices/2011/engine/300/300" xmlns:dwd="http://schemas.microsoft.com/DataWarehouse/Designer/1.0" xsi:type="RelationalDataSource" dwd:design-time-name="f96a8f2d-c218-4b5c-bc0f-8e792fc7c3f5" xmlns="http://schemas.microsoft.com/analysisservices/2003/engine">
<ID>DWWeatherTracker</ID>
<Name>DWWeatherTracker</Name>
<CreatedTimestamp>0001-01-01T08:00:00Z</CreatedTimestamp>
<LastSchemaUpdate>0001-01-01T08:00:00Z</LastSchemaUpdate>
<ConnectionString>Provider=SQLNCLI11.1;Data Source=(local);Integrated Security=SSPI;Initial Catalog=DWWeatherTracker</ConnectionString>
<ConnectionStringSecurity>Unchanged</ConnectionStringSecurity>
<ImpersonationInfo>
<ImpersonationMode>ImpersonateAccount</ImpersonationMode>
<Account>&lt;Your Computer Name Goes Here&gt;\Administrator</Account>
<ImpersonationInfoSecurity>PasswordRemoved</ImpersonationInfoSecurity>
</ImpersonationInfo>
<Timeout>PT0S</Timeout>
</DataSource>

0 comments on commit d4a8157

Please sign in to comment.