Quantcast
Channel: CodeSection,代码区,SQL Server(mssql)数据库 技术分享 - CodeSec
Viewing all articles
Browse latest Browse all 3160

Installing new SQL Server sample databases: WideWorldImporters

$
0
0

By:Koen Verbeeck || Related Tips:More >SQL Server 2016

Problem

With a new release of SQL Server (SQL Server 2016) comes also a new sample database. The days of AdventureWorks are over, here's Wide World Importers! This tip gives an overview of how you can install these new sample databases on your system.

Solution

Wide World Importers (WWI) is the new SQL Server sample database. It aims to give a demonstration of the SQL Server 2016 capabilities and performance enhancements. It doesn't try to embed all possible SQL Server 2016 features, but rather goes for a more realistic approach.

From MSDN :

Wide World Importers (WWI) is a wholesale novelty goods importer and distributor operating from the San Francisco bay area. As a wholesaler, WWIs customers are mostly companies who resell to individuals. WWI sells to retail customers across the United States including specialty stores, supermarkets, computing stores, tourist attraction shops, and some individuals. WWI also sells to other wholesalers via a network of agents who promote the products on WWIs behalf. While all of WWIs customers are currently based in the United States, the company is intending to push for expansion into other countries. WWI buys goods from suppliers including novelty and toy manufacturers, and other novelty wholesalers. They stock the goods in their WWI warehouse and reorder from suppliers as needed to fulfill customer orders. They also purchase large volumes of packaging materials, and sell these in smaller quantities as a convenience for the customers. Recently WWI started to sell a variety of edible novelties such as chilly chocolates. The company previously did not have to handle chilled items. Now, to meet food handling requirements, they must monitor the temperature in their chiller room and any of their trucks that have chiller sections.

Check out the overview page on MSDN to find out more about the workflows for Wide World Importers and other useful information.

Right now, you can download the latest release from GitHub . It's licensed under the MIT license.

The WWI sample databases come in two flavors:

WideWorldImporters - the OLTP sample database. It can also be used to demonstrate operational analytics. Some of the key features that can be used: Nonclustered columnstore indexes for operational real-time analytics Query Store to keep track of query performance Historical data is maintained usingtemporal tables JSON integration Security features likerow level security,data masking andAlways Encrypted In-memory OLTP to optimize performance Clustered columnstore indexes for large tables with an insert-only workload Partitioning WideWorldImportersDW - the OLAP data warehouse for WWI. The data is derived from the WideWorldImporters database. A couple examples of the key features: Clustered columnstore indexes to reduce the size of large tables and to enhance performance Polybase to correlate data with a public data set in Azure Blob storage In-memory OLTP to improve the performance of the ETL process Partitioning

Not all of the features are automatically included. The release comes with a set of sample scripts to allow you to explore the new features. There's also the possibility to enable only features included in the Standard edition.

What sets WWI apart from AdventureWorks is that you can keep the data up to date. With a script, you can refresh the data in the WideWorldImporters database up to the current date. Using the provided ETL flow, you can then refresh the data warehouse as well. You can schedule those scripts to simulate a daily load. The data inside the databases is also not fixed, but randomly generated resulting in a realistic set of data.

In the first part of the tip, we'll focus on the installation of the OLTP database.

Back-up and Restore

The easiest method to install the sample databases is to download the back-up files from GitHub (this URL links to the version 1.0 release) and restore them on your system. In the current release, the data ranges from January 1st, 2013 to May 31st, 2016. You can use a script to load data until the current date. More information on this will be provided at the end of the tip. There are three download options:

Full backups: these are the backups intended for SQL Server 2016 Enterprise, Developer or Evaluation edition. Standard backups: these are the backups intended for SQL Server 2016 Standard edition. These backups have less features enabled. Bacpac for Azure SQL Database. This is Standard Edition.

In order to keep the download size reasonable, the data size is limited. Using the scripts explained in the following section, you can create a larger sample database.

For more information on how to restore a database: How to restore a SQL Server backup .

Creating WideWorldImporters from scratch

Another option to install the sample database is creating it from scratch using T-SQL scripts. The scripts can be found on Github . There are a total of 9 scripts to help you create your own copy of WWI. What's interesting is that data will be randomly generated and you can influence the data size and distribution. You can also choose to date until which the data is generated.

The first script - 1-wwi-metadata-population.sql - creates a metadata database called WWI_Preparation holding all the table, column and schema metadata required to create the sample database.


Installing new SQL Server sample databases: WideWorldImporters

Some table metadata:


Installing new SQL Server sample databases: WideWorldImporters

After running all the scripts, this database can be removed.

The second script - 2-wwi-construct-database-from-metadata-tables.sql - will generate all of the T-SQL required to construct the WWI database. It uses the metadata created in the first script and some system metadata as well.


Installing new SQL Server sample databases: WideWorldImporters

In the result, you can see for example that the data directories for the database files use the server default of your system. You need to copy paste the result and execute it in another query window in order to create the WWI database. Another option is to run the third script called 3-wwi-recreate.sql . This script is optional, as it contains the output of the second script but this time without your system settings.


Installing new SQL Server sample databases: WideWorldImporters
In most cases, the best choice is to run the second script, copy-paste and execute the results instead of r

Viewing all articles
Browse latest Browse all 3160

Trending Articles