Skip to content

Commit b3e19e7

Browse files
authored
Merge pull request MicrosoftDocs#1459 from barbkess/wwi
switch oltp and olap database catalogs
2 parents 553b07b + 942e23b commit b3e19e7

File tree

2 files changed

+218
-218
lines changed

2 files changed

+218
-218
lines changed

docs/sample/world-wide-importers/database-catalog-oltp.md

Lines changed: 168 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -9,93 +9,211 @@ ms.reviewer: ""
99
ms.suite: ""
1010
ms.tgt_pltfrm: ""
1111
ms.topic: "article"
12-
ms.assetid: 5ed65e42-527a-45e7-9a91-7179e892652e
13-
caps.latest.revision: 2
12+
ms.assetid: e47c0022-ce87-4ba5-a24b-df55efe66431
13+
caps.latest.revision: 3
1414
author: "BarbKess"
1515
ms.author: "barbkess"
1616
manager: "jhubbard"
1717
robots: noindex,nofollow
1818
---
19-
# WideWorldImportersDW database catalog
20-
Explanations for the schemas, tables, and stored procedures in the WideWorldImportersDW database.
19+
# Database catalog
20+
The WideWorldImporters database contains all the transaction information and daily data for sales and purchases, as well as sensor data for vehicles and cold rooms.
2121

22-
The WideWorldImportersDW database is used for data warehousing and analytical processing. The transactional data about sales and purchases is generated in the WideWorldImporters database, and loaded into the WideWorldImportersDW database using a **daily ETL process**.
22+
## Schemas
2323

24-
The data in WideWorldImportersDW thus mirrors the data in WideWorldImporters, but the tables are organized differently. While WideWorldImporters has a traditional normalized schema, WideWorldImportersDW uses the [star schema](https://wikipedia.org/wiki/Star_schema) approach for its table design. Besides the fact and dimension tables, the database includes a number of staging tables that are used in the ETL process.
24+
WideWorldImporters uses schemas for different purposes, such as storing data, defining how users can access the data, and providing objects for data warehouse development and integration.
2525

26-
## Schemas
26+
### Data schemas
27+
28+
These schemas contain the data. A number of tables are needed by all other schemas and are located in the Application schema.
29+
30+
|Schema|Description|
31+
|-----------------------------|---------------------|
32+
|Application|Application-wide users, contacts, and parameters. This also contains reference tables with data that is used by multiple schemas|
33+
|Purchasing|Stock item purchases from suppliers and details about suppliers.|
34+
|Sales|Stock item sales to retail customers, and details about customers and sales people. |
35+
|Warehouse|Stock item inventory and transactions.|
36+
37+
### Secure-access schemas
38+
39+
These schemas are used for external applications that are not allowed to access the data tables directly. They contain views and stored procedures used by external applications.
40+
41+
|Schema|Description|
42+
|-----------------------------|---------------------|
43+
|Website|All access to the database from the company website is through this schema.|
44+
|Reports|All access to the database from Reporting Services reports is through this schema.|
45+
|PowerBI|All access to the database from the Power BI dashboards via the Enterprise Gateway is through this schema.|
46+
47+
Note that the Reports and PowerBI schemas are not used in the initial release of the sample database. However, all Reporting Services and Power BI samples built on top of this database are encouraged to use these schemas.
48+
49+
### Development schemas
2750

28-
The different types of tables are organized in three schemas.
51+
Special-purpose schemas
2952

3053
|Schema|Description|
3154
|-----------------------------|---------------------|
32-
|Dimension|Dimension tables.|
33-
|Fact|Fact tables.|
34-
|Integration|Staging tables and other objects needed for ETL.|
55+
|Integration|Objects and procedures required for data warehouse integration (i.e. migrating the data to the WideWorldImportersDW database).|
56+
|Sequences|Holds sequences used by all tables in the application.|
3557

3658
## Tables
3759

38-
The dimension and fact tables are listed below. The tables in the Integration schema are used only for the ETL process, and are not listed.
60+
All tables in the database are in the data schemas.
3961

40-
### Dimension tables
62+
### Application Schema
4163

42-
WideWorldImportersDW has the following dimension tables. The description includes the relationship with the source tables in the WideWorldImporters database.
64+
Details of parameters and people (users and contacts), along with common reference tables (common to multiple other schemas).
4365

44-
|Table|Source tables|
66+
|Table|Description|
4567
|-----------------------------|---------------------|
46-
|City|`Application.Cities`, `Application.StateProvinces`, `Application.Countries`.|
47-
|Customer|`Sales.Customers`, `Sales.BuyingGroups`, `Sales.CustomerCategories`.|
48-
|Date|New table with information about dates, including financial year (based on November 1st start for financial year).|
49-
|Employee|`Application.People`.|
50-
|StockItem|`Warehouse.StockItems`, `Warehouse.Colors`, `Warehouse.PackageType`.|
51-
|Supplier|`Purchasing.Suppliers`, `Purchasing.SupplierCategories`.|
52-
|PaymentMethod|`Application.PaymentMethods`.|
53-
|TransactionType|`Application.TransactionTypes`.|
68+
|SystemParameters|Contains system-wide configurable parameters.|
69+
|People|Contains user names, contact information, for all who use the application, and for the people that the Wide World Importers deals with at customer organizations. This includes staff, customers, suppliers, and any other contacts. For people who have been granted permission to use the system or website, the information includes login details.|
70+
|Cities|There are many addresses stored in the system, for people, customer organization delivery addresses, pickup addresses at suppliers, etc. Whenever an address is stored, there is a reference to a city in this table. There is also a spatial location for each city.|
71+
|StateProvinces|Cities are part of states or provinces. This table has details of those, including spatial data describing the boundaries each state or province.|
72+
|Countries|States or Provinces are part of countries. This table has details of those, including spatial data describing the boundaries of each country.|
73+
|DeliveryMethods|Choices for delivering stock items (e.g., truck/van, post, pickup, courier, etc.)|
74+
|PaymentMethods|Choices for making payments (e.g., cash, check, EFT, etc.)|
75+
|TransactionTypes|Types of customer, supplier, or stock transactions (e.g., invoice, credit note, etc.)|
76+
77+
### Purchasing Schema
78+
79+
Details of suppliers and of stock item purchases.
5480

55-
### Fact tables
81+
|Table|Description|
82+
|-----------------------------|---------------------|
83+
|Suppliers|Main entity table for suppliers (organizations)|
84+
|SupplierCategories|Categories for suppliers (e.g., novelties, toys, clothing, packaging, etc.)|
85+
|SupplierTransactions|All financial transactions that are supplier-related (invoices, payments)|
86+
|PurchaseOrders|Details of supplier purchase orders|
87+
|PurchaseOrderLines|Detail lines from supplier purchase orders|
5688

57-
WideWorldImportersDW has the following fact tables. The description includes the relationship with the source tables in the WideWorldImporters database, as well as the classes of analytics/reporting queries each fact table is typically used with.
89+
90+
### Sales Schema
5891

59-
|Table|Source tables|Sample Analytics|
60-
|-----------------------------|---------------------|---------------------|
61-
|Order|`Sales.Orders` and `Sales.OrderLines`|Sales people, picker/packer productivity, and on time to pick orders. In addition, low stock situations leading to back orders.|
62-
|Sale|`Sales.Invoices` and `Sales.InvoiceLines`|Sales dates, delivery dates, profitability over time, profitability by sales person.|
63-
|Purchase|`Purchasing.PurchaseOrderLines`|Expected vs actual lead times|
64-
|Transaction|`Sales.CustomerTransactions` and `Purchasing.SupplierTransactions`|Measuring issue dates vs finalization dates, and amounts.|
65-
|Movement|`Warehouse.StockTransactions`|Movements over time.|
66-
|Stock Holding|`Warehouse.StockItemHoldings`|On-hand stock levels and value.|
92+
Details of customers, salespeople, and of stock item sales.
6793

68-
## Stored procedures
94+
|Table|Description|
95+
|-----------------------------|---------------------|
96+
|Customers|Main entity tables for customers (organizations or individuals)|
97+
|CustomerCategories|Categories for customers (ie novelty stores, supermarkets, etc.)|
98+
|BuyingGroups|Customer organizations can be part of groups that exert greater buying power|
99+
|CustomerTransactions|All financial transactions that are customer-related (invoices, payments)|
100+
|SpecialDeals|Special pricing. This can include fixed prices, discount in dollars or discount percent.|
101+
|Orders|Detail of customer orders|
102+
|OrderLines|Detail lines from customer orders|
103+
|Invoices|Details of customer invoices|
104+
|InvoiceLines|Detail lines from customer invoices|
69105

70-
The stored procedures are used primarily for the ETL process and for configuration purposes.
106+
### Warehouse Schema
71107

72-
Any extensions of the sample are encouraged to use the `Reports` schema for Reporting Services reports, and the `PowerBI` schema for Power-BI access.
108+
Details of stock items, their holdings and transactions.
73109

74-
### Application Schema
110+
|Table|Description|
111+
|-----------------------------|---------------------|
112+
|StockItems|Main entity table for stock items|
113+
|StockItemHoldings|Non-temporal columns for stock items. These arefrequently updated columns.|
114+
|StockGroups|Groups for categorizing stock items (e.g., novelties, toys, edible novelties, etc.)|
115+
|StockItemStockGroups|Which stock items are in which stock groups (many to many)|
116+
|Colors|Stock items can (optionally) have colors|
117+
|PackageTypes|Ways that stock items can be packaged (e.g., box, carton, pallet, kg, etc.|
118+
|StockItemTransactions|Transactions covering all movements of all stock items (receipt, sale, write-off)|
119+
|VehicleTemperatures|Regularly recorded temperatures of vehicle chillers|
120+
|ColdRoomTemperatures|Regularly recorded temperatures of cold room chillers|
121+
122+
123+
## Design considerations
124+
125+
Database design is subjective and there is no right or wrong way to design a database. The schemas and tables in this database show ideas for how you can design your own database.
126+
127+
### Schema design
128+
129+
WideWorldImporters uses a small number of schemas so that it is easy to understand the database system and demonstrate database principles.
75130

76-
These procedures are used to configure the sample. They are used to apply enterprise edition features to the standard edition version of the sample, add PolyBase, and reseed ETL.
131+
Wherever possible, the database collocates tables that are commonly queried together into the same schema to minimize join complexity.
132+
133+
The database schema has been code-generated based on a series of metadata tables in another database WWI_Preparation. This gives WideWorldImporters a very high degree of design consistency, naming consistency, and completeness. For details on how the schema has been generated see the source code: [wide-world-importers/wwi-database-scripts](https://github.com/Microsoft/sql-server-samples/tree/master/samples/databases/wide-world-importers/wwi-database-scripts)
134+
135+
### Table design
136+
137+
- All tables have single column primary keys for join simplicity.
138+
- All schemas, tables, columns, indexes, and check constraints have a Description extended property that can be used to identify the purpose of the object or column. Memory-optimized tables are an exception to this since they don’t currently support extended properties.
139+
- All foreign keys are automatically indexed unless there is another non-clustered index that has the same left-hand component.
140+
- Auto-numbering in tables is based on sequences. These sequences are easier to work with across linked servers and similar environments than IDENTITY columns. Memory-optimized tables use IDENTITY columns since they don’t support in SQL Server 2016.
141+
- A single sequence (TransactionID) is used for these tables: CustomerTransactions, SupplierTransactions, and StockItemTransactions. This demonstrates how a set of tables can have a single sequence.
142+
- Some columns have appropriate default values.
143+
144+
### Security schemas
145+
146+
For security, WideWorldImporters does not allow external applications to access data schemas directly. To isolate access, WideWorldImporters uses security-access schemas that do not hold data, but contain views and stored procedures. External applications use the security schemas to retrieve the data that they are allowed to view. This way, users can only run the views and stored procedures in the secure-access schemas
147+
148+
For example, this sample includes Power BI dashboards. An external application accesses these Power BI dashboards from the Power BI gateway as a user that has read-only permission on the PowerBI schema. For read-only permission, the user only needs SELECT and EXECUTE permission on the PowerBI schema. A database administrator at WWI assigns these permissions as needed.
149+
150+
## Stored Procedures
151+
152+
Stored procedures are organized in schemas. Most of the schemas are used for configuration or sample purposes.
153+
154+
The `Website` schema contains the stored procedures that can be used by a Web front-end.
155+
156+
The `Reports` and `PowerBI` schemas are meant for reporting services and PowerBI purposes. Any extensions of the sample are encouraged to use these schemas for reporting purposes.
157+
158+
### Website schema
159+
160+
These are the procedures used by a client application, such as a Web front-end.
77161

78162
|Procedure|Purpose|
79163
|-----------------------------|---------------------|
80-
|Configuration_ApplyPartitionedColumnstoreIndexing|Applies both partitioning and columnstore indexes for fact tables.|
81-
|Configuration_ConfigureForEnterpriseEdition|Applies partitioning, columnstore indexing and in-memory.|
82-
|Configuration_EnableInMemory|Replaces the integration staging tables with SCHEMA_ONLY memory-optimized tables to improve ETL performance.|
83-
|Configuration_ApplyPolybase|Configures an external data source, file format, and table.|
84-
|Configuration_PopulateLargeSaleTable|Applied enterprise edition changes, then populates a larger amount of data for the 2012 calendar year as additional history.|
85-
|Configuration_ReseedETL|Removes existing data and restarts the ETL seeds. This allows for repopulating the OLAP database to match updated rows in the OLTP database.|
164+
|ActivateWebsiteLogon|Allows a person (from `Application.People`) to have access to the website.|
165+
|ChangePassword|Changes a user’s password (for users that are not using external authentication mechanisms).|
166+
|InsertCustomerOrders|Allows inserting one or more customer orders (including the order lines).|
167+
|InvoiceCustomerOrders|Takes a list of orders to be invoiced and processes the invoices.|
168+
|RecordColdRoomTemperatures|Takes a sensor data list, as a table-valued parameter (TVP), and applies the data to the `Warehouse.ColdRoomTemperatures` temporal table.|
169+
|RecordVehicleTemperature|Takes a JSON array and uses it to update `Warehouse.VehicleTemperatures`.|
170+
|SearchForCustomers|Searches for customers by name or part of name (either the company name or the person name).|
171+
|SearchForPeople|Searches for people by name or part of name.|
172+
|SearchForStockItems|Searches for stock items by name or part of name or marketing comments.|
173+
|SearchForStockItemsByTags|Searches for stock items by tags.|
174+
|SearchForSuppliers|Searches for suppliers by name or part of name (either the company name or the person name).|
86175

87176
### Integration Schema
88177

89-
Procedures used in the ETL process fall in these categories:
90-
- Helper procedures for the ETL package - All Get* procedures.
91-
- Procedures used by the ETL package for migrating staged data into the DW tables - All Migrate* procedures.
92-
- `PopulateDateDimensionForYear` - Takes a year and ensures that all dates for that year are populated in the `Dimension.Date` table.
178+
The stored procedures in this schema are used by the ETL process. They obtain the data needed from various tables for the timeframe required by the [ETL package](https://msdn.microsoft.com/library/mt734218.aspx).
179+
180+
### DataLoadSimulation Schema
181+
182+
Simulates a workload that inserts sales and purchases. The main stored procedure is `PopulateDataToCurrentDate`, which is used to insert sample data up to the current date.
183+
184+
|Procedure|Purpose|
185+
|-----------------------------|---------------------|
186+
|Configuration_ApplyDataLoadSimulationProcedures|Recreates the procedures needed for data load simulation. This is needed for bringing data up to the current date.|
187+
|Configuration_RemoveDataLoadSimulationProcedures|This removes the procedures again after data simulation is complete.|
188+
|DeactiveTemporalTablesBeforeDataLoad|Removes the temporal nature of all temporal tables and where applicable, applies a trigger so that changes can be made as though they were being applied at an earlier date than the sys-temporal tables allow.|
189+
|PopulateDataToCurrentDate|Used to bring the data up to the current date. Should be run before any other configuration options after restoring the database from an initial backup.|
190+
|ReactivateTemporalTablesAfterDataLoad|Re-establishes the temporal tables, including checking for data consistency. (Removes the associated triggers).|
191+
192+
193+
### Application Schema
194+
195+
These procedures are used to configure the sample. They are used to apply enterprise edition features to the standard edition version of the sample, and also to add auditing and full-text indexing.
196+
197+
|Procedure|Purpose|
198+
|-----------------------------|---------------------|
199+
|AddRoleMemberIfNonexistant|Adds a member to a role if the member isn’t already in the role|
200+
|Configuration_ApplyAuditing|Adds auditing. Server auditing is applied for standard edition databases; additional database auditing is added for enterprise edition.|
201+
|Configuration_ApplyColumnstoreIndexing|Applies columnstore indexing to `Sales.OrderLines` and `Sales.InvoiceLines` and reindexes appropriately.|
202+
|Configuration_ApplyFullTextIndexing|Applies fulltext indexes to `Application.People`, `Sales.Customers`, `Purchasing.Suppliers`, and `Warehouse.StockItems`. Replaces `Website.SearchForPeople`, `Website.SearchForSuppliers`, `Website.SearchForCustomers`, `Website.SearchForStockItems`, `Website.SearchForStockItemsByTags` with replacement procedures that use fulltext indexing.|
203+
|Configuration_ApplyPartitioning|Applies table partitioning to `Sales.CustomerTransactions and `Purchasing.SupplierTransactions`, and rearranges the indexes to suit.|
204+
|Configuration_ApplyRowLevelSecurity|Applies row level security to filter customers by sales territory related roles.|
205+
|Configuration_ConfigureForEnterpriseEdition|Applies columnstore indexing, full text, in-memory, polybase, and partitioning.|
206+
|Configuration_EnableInMemory|Adds a memory-optimized filegroup (when not working in Azure), replaces `Warehouse.ColdRoomTemperatures`, `Warehouse.VehicleTemperatures` with in-memory equivalents, and migrates the data, recreates the `Website.OrderIDList`, `Website.OrderList`, `Website.OrderLineList`, `Website.SensorDataList` table types with memory-optimized equivalents, drops and recreates the procedures `Website.InvoiceCustomerOrders`, `Website.InsertCustomerOrders`, and `Website.RecordColdRoomTemperatures` that uses these table types.|
207+
|Configuration_RemoveAuditing|Removes the auditing configuration.|
208+
|Configuration_RemoveRowLevelSecurity|Removes the row level security configuration (this is needed for changes to the associated tables).|
209+
|CreateRoleIfNonExistant|Creates a database role if it doesn’t already exist.|
210+
93211

94212
### Sequences Schema
95213

96214
Procedures to configure the sequences in the database.
97215

98216
|Procedure|Purpose|
99217
|-----------------------------|---------------------|
100-
|ReseedAllSequences|Calls the procedure `ReseedSequenceBeyondTableValue` for all sequences.|
101-
|ReseedSequenceBeyondTableValue|Used to reposition the next sequence value beyond the value in any table that uses the same sequence. (Like a `DBCC CHECKIDENT` for identity columns equivalent for sequences but across potentially multiple tables).|
218+
|ReseedAllSequences|Calls the procedure ReseedSequenceBeyondTableValue for all sequences.|
219+
|ReseedSequenceBeyondTableValue|Used to reposition the next sequence value beyond the value in any table that uses the same sequence. (Like a DBCC CHECKIDENT for identity columns equivalent for sequences but across potentially multiple tables).|

0 commit comments

Comments
 (0)