mirror of
https://github.com/Microsoft/sql-server-samples.git
synced 2025-12-08 14:58:54 +00:00
initial versions of catalog and SQL features mapping
This commit is contained in:
@@ -1,7 +1,129 @@
|
||||
# WideWorldImporters Database Catalog
|
||||
|
||||
This folder contains documentation for the sample.
|
||||
The WideWorldImporters database contains all the transaction information and daily data for sales and purchases.
|
||||
|
||||
Start with [root.md](root.md)
|
||||
## Schemas
|
||||
|
||||
Note that these contents will most likely be migrated to MSDN.
|
||||
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.
|
||||
|
||||
### Data schemas
|
||||
|
||||
These schemas contain the data. A number of tables are needed by all other schemas and are located in the Application schema.
|
||||
|
||||
|Schema|Description|
|
||||
|-----------------------------|---------------------|
|
||||
|Application|Application-wide users, contacts, and parameters. This also contains reference tables with data that is used by multiple schemas|
|
||||
|Purchasing|Stock item purchases from suppliers and details about suppliers.|
|
||||
|Sales|Stock item sales to retail customers, and details about customers and sales people. |
|
||||
|Warehouse|Stock item inventory and transactions.|
|
||||
|
||||
### Secure-access schemas
|
||||
|
||||
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.
|
||||
|
||||
|Schema|Description|
|
||||
|-----------------------------|---------------------|
|
||||
|Website|All access to the database from the company website is through this schema.|
|
||||
|Reports|All access to the database from Reporting Services reports is through this schema.|
|
||||
|PowerBI|All access to the database from the Power BI dashboards via the Enterprise Gateway is through this schema.|
|
||||
|
||||
### Development schemas
|
||||
|
||||
Special-purpose schemas
|
||||
|
||||
|Schema|Description|
|
||||
|-----------------------------|---------------------|
|
||||
|Integration|Objects and procedures required for data warehouse integration (i.e. migrating the data to the WideWorldImportersDW database).|
|
||||
|Sequences|Holds sequences used by all tables in the application.|
|
||||
|
||||
## Tables
|
||||
|
||||
All tables in the database are in the data schemas.
|
||||
|
||||
### Application Schema
|
||||
|
||||
Details of parameters and people (users and contacts), along with common reference tables (common to multiple other schemas).
|
||||
|
||||
|Table|Description|
|
||||
|-----------------------------|---------------------|
|
||||
|SystemParameters|Contains system-wide configurable parameters.|
|
||||
|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.|
|
||||
|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.|
|
||||
|StateProvinces|Cities are part of states or provinces. This table has details of those, including spatial data describing the boundaries each state or province.|
|
||||
|Countries|States or Provinces are part of countries. This table has details of those, including spatial data describing the boundaries of each country.|
|
||||
|DeliveryMethods|Choices for delivering stock items (e.g., truck/van, post, pickup, courier, etc.)|
|
||||
|PaymentMethods|Choices for making payments (e.g., cash, check, EFT, etc.)|
|
||||
|TransactionTypes|Types of customer, supplier, or stock transactions (e.g., invoice, credit note, etc.)|
|
||||
|
||||
### Purchasing Schema
|
||||
|
||||
Details of suppliers and of stock item purchases.
|
||||
|
||||
|Table|Description|
|
||||
|-----------------------------|---------------------|
|
||||
|Suppliers|Main entity table for suppliers (organizations)|
|
||||
|SupplierCategories|Categories for suppliers (e.g., novelties, toys, clothing, packaging, etc.)|
|
||||
|SupplierTransactions|All financial transactions that are supplier-related (invoices, payments)|
|
||||
|PurchaseOrders|Details of supplier purchase orders|
|
||||
|PurchaseOrderLines|Detail lines from supplier purchase orders|
|
||||
|
||||
|
||||
### Sales Schema
|
||||
|
||||
Details of customers, salespeople, and of stock item sales.
|
||||
|
||||
|Table|Description|
|
||||
|-----------------------------|---------------------|
|
||||
|Customers|Main entity tables for customers (organizations or individuals)|
|
||||
|CustomerCategories|Categories for customers (ie novelty stores, supermarkets, etc.)|
|
||||
|BuyingGroups|Customer organizations can be part of groups that exert greater buying power|
|
||||
|CustomerTransactions|All financial transactions that are customer-related (invoices, payments)|
|
||||
|SpecialDeals|Special pricing. This can include fixed prices, discount in dollars or discount percent.|
|
||||
|Orders|Detail of customer orders|
|
||||
|OrderLines Detail lines from customer orders|
|
||||
|Invoices|Details of customer invoices|
|
||||
|InvoiceLines|Detail lines from customer invoices|
|
||||
|
||||
### Warehouse Schema
|
||||
|
||||
Details of stock items, their holdings and transactions.
|
||||
|
||||
|Table|Description|
|
||||
|-----------------------------|---------------------|
|
||||
|StockItems|Main entity table for stock items|
|
||||
|StockItemHoldings|Non-temporal columns for stock items. These arefrequently updated columns.|
|
||||
|StockGroups|Groups for categorizing stock items (e.g., novelties, toys, edible novelties, etc.)|
|
||||
|StockItemStockGroups|Which stock items are in which stock groups (many to many)|
|
||||
|Colors|Stock items can (optionally) have colors|
|
||||
|PackageTypes|Ways that stock items can be packaged (e.g., box, carton, pallet, kg, etc.|
|
||||
|StockItemTransactions|Transactions covering all movements of all stock items (receipt, sale, write-off)|
|
||||
|VehicleTemperatures|Regularly recorded temperatures of vehicle chillers|
|
||||
|ColdRoomTemperatures|Regularly recorded temperatures of cold room chillers|
|
||||
|
||||
|
||||
## Design considerations
|
||||
|
||||
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.
|
||||
|
||||
### Schema design
|
||||
|
||||
WideWorldImporters uses a small number of schemas so that it is easy to understand the database system and demonstrate database principles.
|
||||
|
||||
Wherever possible, the database collocates tables that are commonly queried together into the same schema to minimize join complexity.
|
||||
|
||||
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)
|
||||
|
||||
### Table design
|
||||
|
||||
- All tables have single column primary keys for join simplicity.
|
||||
- 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.
|
||||
- All foreign keys are automatically indexed unless there is another non-clustered index that has the same left-hand component.
|
||||
- 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.
|
||||
- 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.
|
||||
- Some columns have appropriate default values.
|
||||
|
||||
### Security schemas
|
||||
|
||||
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
|
||||
|
||||
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.
|
||||
|
||||
@@ -1,7 +1,51 @@
|
||||
# WideWorldImporters Use of SQL Server Features and Capabilities
|
||||
|
||||
This folder contains documentation for the sample.
|
||||
WideWorldImporters is designed to showcase many of the key features of SQL Server, including the latest features introduced in SQL Server 2016. The following is a list of SQL Server features and capabilities, and a description of how they are used in WideWorldImporters.
|
||||
|
||||
Start with [root.md](root.md)
|
||||
|
||||
Note that these contents will most likely be migrated to MSDN.
|
||||
|SQL Server feature or capability|Use in WideWorldImporters|
|
||||
|Temporal tables|There are many temporal tables, including all look-up style reference tables and main entities such as StockItems, Customers, and Suppliers. Using temporal tables allows to conveniently keep track of the history of these entities.|
|
||||
|AJAX calls for JSON|The application frequently uses AJAX calls to query these tables: Persons, Customers, Suppliers, and StockItems. The calls return JSON payloads (i.e. the data that is returned is formatted as JSON data). See, for example, the stored procedure `Website.SearchForCustomers`.|
|
||||
|Row-level security (RLS)|Row Level Security (RLS) is used to limit access to the Customers table, based on role membership. Each sales territory has a role and a user. To see this in action, a script to demonstrate it has been provided.|
|
||||
|Full-text indexes|Full-text indexes improve searches for People, Customers, and StockItems. The indexes are applied to queries only if you have full-text indexing installed on your SQL Server instance.
|
||||
A non-persistent computed column is used to create the data that is full-text indexed in the StockItems table.
|
||||
<br/>
|
||||
`CONCAT` is used for concatenating the fields to create SearchData that is full-text indexed.
|
||||
<br/>
|
||||
To enable the use of full-text indexes in the sample execute the following statement in the database:
|
||||
<br/>
|
||||
EXECUTE [Application].[Configuration_ConfigureFullTextIndexing]
|
||||
<br/>
|
||||
The procedure creates a default fulltext catalog if one doesn’t already exist, then replaces the search views with full-text versions of those views).
|
||||
<br/>
|
||||
Note that using full-text indexes in SQL Server requires selecting the Full-Text option during installation. Azure SQL Database does not require and specific configuration to enable full-text indexes.|
|
||||
|In-Memory OLTP|(Full version of the database) The table types are all memory-optimized, such that table-valued parameters (TVPs) all benefit from memory-optimization.
|
||||
<br/>
|
||||
The two monitoring tables, `Warehouse.VehicleTemperatures` and `Warehouse.ColdRoomTemperatures`, are memory-optimized. This allows the ColdRoomTemperatures table to be populated at higher speed than a traditional disk-based table. The VehicleTemperatures table holds the JSON payload and lends itself to extension towards IoT scenarios. The VehicleTemperatures table further lends itself to scenarios involving EventHubs, Stream Analytics, and Power BI.
|
||||
<br/>
|
||||
The stored procedure `Website.RecordColdRoomTemperatures` is natively compiled to further improve the performance of recording cold room temperatures.|
|
||||
|Real-time Operational Analytics|(Full version of the database) The core transactional tables `Sales.InvoiceLines` and `Sales.OrderLines` both have a non-clustered columnstore index to support efficient execution of analytical queries in the operational database with minimal impact on the operational workload.|
|
||||
|Dynamic Data Masking|In the database schema, Data Masking has been applied to the bank details held for Suppliers, in the table `Purchasing.Suppliers`. Non-admin staff will not have access to this information.|
|
||||
|Always Encrypted|The AccountNumber field uses AlwaysEncrypted. Unfortunately, at present, it cannot also use data masking.
|
||||
<br/
|
||||
A demo for Always Encrypted is included in the downloadable samples.zip. The demo creates an encryption key, a table using encryption for sensitive data, and a small sample application that inserts data into the table.|
|
||||
|Stretch database|The `Warehouse.ColdRoomTemperatures` table has been implemented as a temporal table, and is memory-optimized in the Full version of the sample database. The archive table is disk-based and can be stretched to Azure.|
|
||||
|Indexed persisted computed columns|Indexed persisted computed columns used in SupplierTransactions and CustomerTransactions.|
|
||||
|Check constraints|A relatively complex check constraint is in `Sales.SpecialDeals`. This ensures that one and only one of DiscountAmount, DiscountPercentage, and UnitPrice is configured.|
|
||||
|Unique constraints|A many to many construction (and unique constraints) are set up for Warehouse.StockItemStockGroups`.|
|
||||
|Clustered columnstore index|(Full version of the database) The table `Warehouse.StockItemTransactions` uses a clustered columnstore index. The number of rows in this table is expected to grow large, and the clustered columnstore index significantly reduces the on-disk size of the table, and improves query performance. The modification on this table are insert-only - there is no update/delete on this table in the online workload - and clustered columnstore index performs well for insert workloads.|
|
||||
|Table partitioning|(Full version of the database) The tables `Sales.CustomerTransactions` and `Purchasing.SupplierTransactions` are both partitioned by year using the partition function `PF_TransactionDate` and the partition scheme `PS_TransactionDate`. Partitioning is used to improve the manageability of large tables.|
|
||||
|List processing|An example table type `Website.OrderIDList` is provided. It is used by an example procedure `Website.InvoiceCustomerOrders`. The procedure uses Common Table Expressions (CTEs), TRY/CATCH, JSON_MODIFY, XACT_ABORT, NOCOUNT, THROW, and XACT_STATE to demonstrates the ability to process a list of orders rather than just a single order, to minimize round trips from the application to the database engine.|
|
||||
|GZip compression|The `Warehouse.VehicleTemperature`s table holds full sensor data but when this data is more than a few months old, it is compressed to conserve space using the COMPRESS function, which uses GZip compression.
|
||||
<br/>
|
||||
The view `Website.VehicleTemperatures` uses the DECOMPRESS function when retrieving data that was previously compressed.|
|
||||
|Query Store|Query Store is enabled on the database. After running a few queries, open the database in Management Studio, open the node Query Store, which is under the database, and open the report Top Resource Consuming Queries to see the query executions and the plans for the queries you just ran.|
|
||||
|STRING_SPLIT|The column `DeliveryInstructions` in the table `Sales.Invoices`has a comma-delimited value that can be used to demonstrate STRING_SPLIT.|
|
||||
|Audit|SQL Server Audit can be enabled for this sample database by running the following statement in the database:
|
||||
<br/>
|
||||
EXECUTE [Application].[Configuration_ApplyAuditing]
|
||||
<br/>
|
||||
In Azure SQL Database, auditing is enabled through the [Azure portal](https://portal.azure.com/).
|
||||
<br/>
|
||||
Security operations involving logins, roles and permissions are logged on all systems where audit is enabled (including standard edition systems). Audit is directed to the application log because this is available on all systems and does not require additional permissions. A warning is given that for higher security, it should be redirected to the security log or to a file in a secure folder. A link is provided to describe the required additional configuration.
|
||||
<br/>
|
||||
For evaluation/developer/enterprise edition systems, access to all financial transactional data is audited.|
|
||||
|
||||
Reference in New Issue
Block a user