9
Hands-On Lab Your First Look at the SQL Server 2008 R2 Sample Databases Lab version: 1.0.0 Last updated: 8/23/2022

SQL10R2BYFBI01-HOL-01

Embed Size (px)

Citation preview

Page 1: SQL10R2BYFBI01-HOL-01

Hands-On LabYour First Look at the SQL Server 2008 R2 Sample Databases

Lab version: 1.0.0

Last updated: 4/11/2023

Page 2: SQL10R2BYFBI01-HOL-01

CONTENTS

OVERVIEW................................................................................................................................................. 3

EXERCISE 1: EXPLORING THE ADVENTURE WORKS DATABASES...................................................4Task 1 – Exploring the AdventureWorks2008R2 Database..................................................................4

Task 2 – Exploring the AdventureWorksDW2008R2 Database............................................................6

Task 3 – Creating the Reseller Sales Database Diagram.......................................................................6

Task 4 – Adding an Annotation to the Database Diagram...................................................................7

Task 5 – Exploring the Database Diagram............................................................................................7

Task 6 – Finishing Up...........................................................................................................................8

SUMMARY.................................................................................................................................................. 8

Page 3: SQL10R2BYFBI01-HOL-01

Overview

This lab introduces the Adventure Works sample databases. The lab scenarios in this course center around the sales activites of the Adventure Works company. Adventure Works manufactures and sells bicycles and related products to various global markets via reseller and internet channels.

Note: Before you start with this exercise you must ensure that your machine meets the system requirements detailed in the next section. Additionally, you must complete the setup steps described in the next section.

Objectives

The objectives of this exercise are to:

Explore the AdventureWorks2008R2 database

Explore the AdventureWorksDW2008R2 database

Create a database diagram for the Reseller Sales subject area of the AdventureWorksDW2008R2 database

System Requirements

You must have installed the following items to complete this lab:

Microsoft SQL Server 2008 R2 Express or higher:

◦ Database Engine

◦ SQL Server Management Studio

SQL Server AdventureWorks2008 R2 sample databases

◦ AdventureWorksDW2008R2

Note: The Full-text search and File Stream features must be installed and enabled in the SQL instance in order to successfully install the AdventureWorks 2008 R2 databases.

For more information about enabling the File Stream feature, see: http://msdn.microsoft.com/en-us/library/cc645923.aspx

Setup

Page 4: SQL10R2BYFBI01-HOL-01

All the requisites for this lab are verified using the Configuration Wizard. To make sure that everything is correctly configured, follow these steps.

Note: To perform the setup steps you need to run the scripts in a command window with administrator privileges.

1. Launch the Configuration Wizard for this lab by double-clicking the Dependencies.dep file located under the Source\Setup folder of this lab. Install any pre-requisites that are missing (rescanning if necessary) and complete the wizard.

Cleanup

There is no need to cleanup if you intend to continue the sequence of labs in this training kit.

1. To restore the original state of the AdventureWorksDW2008R2 database, execute the Cleanup.cmd script located under the Setup folder in the Source folder of this lab.

Exercises

This Hands-On Lab comprises the following exercise:

1. Exploring the Adventure Works Databases

Estimated time to complete this lab: 15 minutes.

Exercise 1: Exploring the Adventure Works Databases

In this exercise, you will explore both the AdventureWorks2008R2 and AdventureWorksDW2008R2 databases. The AdventureWorks2008R2 database represents an OLTP database; the AdventureWorksDW2008R2 represents the data warehouse and consists of two subject areas: Sales and Finance. You will then create a database diagram for the Reseller Sales subject area of the AdventureWorksDW2008R2 database.

Task 1 – Exploring the AdventureWorks2008R2 Database

In this task, you will use SQL Server Management Studio to explore the tables in the AdventureWorks2008R2 database.

Page 5: SQL10R2BYFBI01-HOL-01

1. Open SQL Server Management Studio from Start | All Programs | Microsoft SQL Server 2008 R2 | SQL Server Management Studio.

2. When prompted, in the Connect to Server window, configure the connection based on the following values, and then click Connect.

Note: If you are not prompted to connect, first ensure that the Object Explorer window is open. If the Object Explorer window is not open, on the View menu, select Object Explorer. Then, inside the Object Explorer window, click Connect, and then select Database Engine.

Figure 1Connecting to the Database Engine

3. Inside the Object Explorer window, expand the Databases folder, and then expand the AdventureWorks2008R2 database.

4. Expand the Tables folder and note the large list of tables.

Note: The tables are grouped by schema name, including HumanResources, Production, Purchasing and Sales. Realistically, each of these schemas would likely be a separate database.

5. In the Object Explorer pane, collapse the AdventureWorks2008R2 database folder.

Task 2 – Exploring the AdventureWorksDW2008R2 Database

Page 6: SQL10R2BYFBI01-HOL-01

In this task, you will use SQL Server Management Studio to explore the tables in the AdventureWorksDW2008R2 database.

1. In the Object Explorer window, expand the AdventureWorksDW2008R2 database folder.

2. Expand the Tables folder and note the list of tables.

Note: The tables in the data warehouse are prefixed with either Dim or Fact denoting their role in the star schema.

Task 3 – Creating the Reseller Sales Database Diagram

In this task, you will use SQL Server Management Studio to create a database diagram that includes the FactResellerSales and FactSalesQuota tables, and their associated dimension tables.

1. To create a new database diagram, in the Object Explorer window, in the AdventureWorksDW2008R2 database, right-click the Database Diagrams folder, and then select New Database Diagram.

2. If prompted to create the support objects, click Yes.

3. To introduce tables to the database diagram, in the Add Table window, select the DimDate table. Then, while pressing the Control key, select the following additional tables, and then click Add.

Table

DimEmployee

DimProduct

DimProductCategory

DimProductSubcategory

DimSalesTerritory

FactResellerSales

FactSalesQuota

4. When the tables have been added to the database diagram, in the Add Table window, click Close.

Note: SQL Server Management Studio’s database diagramming tool retrieves the metadata that describes each table, including its columns, primary key and any foreign keys to related tables. It then arranges the tables in an easy to read layout.

Page 7: SQL10R2BYFBI01-HOL-01

Task 4 – Adding an Annotation to the Database Diagram

In this task, you will add an annotation to provide a title for the diagram.

1. Scroll to the top of the diagram.

2. To add an annotation, right-click in the top left corner of the diagram, and then select New Text Annotation.

3. Inside the annotation box, type Adventure Works Reseller Sales.

4. To format the annotation, right-click the border of the annotation box, and then select Set Text Annotation Font.

5. In the Font window, modify the Size property to 20, and then click OK.

6. If necessary, resize the annotation box to allow the entire text to be displayed by dragging the middle squares located on the borders.

Task 5 – Exploring the Database Diagram

In this task, you will explore the tables and relationships in the database diagram.

Note: To facilitate exploring the database diagram, click on the four-headed arrow located in the bottom right corner. While continuing to hold the click, drag about the thumbnail view to navigate across the diagram.

Figure 2Navigating the Database Diagram

1. Explore the database diagram to understand the table and relationship design. In particular note the following:

◦ The two fact tables comprised of dimension foreign keys and measures

◦ The relationships from the two fact tables to the single conformed Date and Employee dimension tables

◦ The snowflake Product dimension tables (DimProductCategory > DimProductSubcategory > DimProduct)

◦ The StartDate and EndDate columns in the DimEmployee and DimProduct tables that suggest Type 2 Slowly Changing Dimensions are managed

Page 8: SQL10R2BYFBI01-HOL-01

◦ The self-referencing relationship on the Employee dimension table to support a parent-child hierarchy

Task 6 – Finishing Up

In this task, you will finish up by saving the database diagram and closing all open applications.

1. To save the database diagram, on File menu, select Save Diagram_0.

2. In the Choose Name window, replace the text with Reseller Sales, and then click OK.

3. In the Object Explorer window, in the AdventureWorksDW2008R2 database, expand the Database Diagrams folder, and then verify that your diagram has been saved.

4. To close SQL Server Management Studio, on the File menu, select Exit.

Summary

In this lab, you have explored the two Adventure Works sample databases and produced a database diagram for the Reseller Sales subject area of the AdventureWorksDW2008R2 database.