WideWorldImporters
Sales.SpecialDeals
//
Special pricing (can include fixed prices, discount $ or discount %)
Created: Modified:
Columns
-
//${escapify(column.description)}[int] NOT NULL DEFAULT (NEXT VALUE FOR [Sequences].[SpecialDealID])
-
//${escapify(column.description)}[int] NULL
-
//${escapify(column.description)}[int] NULL
-
//${escapify(column.description)}[int] NULL
-
//${escapify(column.description)}[int] NULL
-
//${escapify(column.description)}[int] NULL
-
//${escapify(column.description)}[nvarchar](30) NOT NULL
-
//${escapify(column.description)}[date] NOT NULL
-
//${escapify(column.description)}[date] NOT NULL
-
//${escapify(column.description)}[decimal](18, 2) NULL
-
//${escapify(column.description)}[decimal](18, 3) NULL
-
//${escapify(column.description)}[decimal](18, 2) NULL
-
[int] NOT NULL
-
[datetime2](8) NOT NULL DEFAULT (sysdatetime())
Indexes
-
PK_Sales_SpecialDealsUNIQUE CLUSTEREDSpecialDealID
-
//Auto-created to support a foreign keyFK_Sales_SpecialDeals_StockItemIDNONCLUSTEREDStockItemID
-
//Auto-created to support a foreign keyFK_Sales_SpecialDeals_CustomerIDNONCLUSTEREDCustomerID
-
//Auto-created to support a foreign keyFK_Sales_SpecialDeals_BuyingGroupIDNONCLUSTEREDBuyingGroupID
-
//Auto-created to support a foreign keyFK_Sales_SpecialDeals_CustomerCategoryIDNONCLUSTEREDCustomerCategoryID
-
//Auto-created to support a foreign keyFK_Sales_SpecialDeals_StockGroupIDNONCLUSTEREDStockGroupID
Foreign Keys
-
FK_Sales_SpecialDeals_Application_PeopleApplication.PeopleLastEditedBy ⥱ PersonID
-
FK_Sales_SpecialDeals_BuyingGroupID_Sales_BuyingGroupsSales.BuyingGroupsBuyingGroupID ⥱ BuyingGroupID
-
FK_Sales_SpecialDeals_CustomerCategoryID_Sales_CustomerCategoriesSales.CustomerCategoriesCustomerCategoryID ⥱ CustomerCategoryID
-
FK_Sales_SpecialDeals_CustomerID_Sales_CustomersSales.CustomersCustomerID ⥱ CustomerID
-
FK_Sales_SpecialDeals_StockGroupID_Warehouse_StockGroupsWarehouse.StockGroupsStockGroupID ⥱ StockGroupID
-
FK_Sales_SpecialDeals_StockItemID_Warehouse_StockItemsWarehouse.StockItemsStockItemID ⥱ StockItemID
Check Constraints
-
//Ensures that each special price row contains one and only one of DiscountAmount, DiscountPercentage, and UnitPriceCK_Sales_SpecialDeals_Exactly_One_NOT_NULL_Pricing_Option_Is_Required(((case when [DiscountAmount] IS NULL then (0) else (1) end+case when [DiscountPercentage] IS NULL then (0) else (1) end)+case when [UnitPrice] IS NULL then (0) else (1) end)=(1))
-
//Ensures that if a specific price is allocated that it applies to a specific stock itemCK_Sales_SpecialDeals_Unit_Price_Deal_Requires_Special_StockItem([StockItemID] IS NOT NULL AND [UnitPrice] IS NOT NULL OR [UnitPrice] IS NULL)
Sample Data
SpecialDealID
StockItemID
CustomerID
BuyingGroupID
CustomerCategoryID
StockGroupID
DealDescription
StartDate
EndDate
DiscountAmount
DiscountPercentage
UnitPrice
LastEditedBy
LastEditedWhen
1
NULL
NULL
2
NULL
7
10% 1st qtr USB Wingtip
NULL
10
NULL
2
2
NULL
NULL
1
NULL
7
15% 2nd qtr USB Tailspin
NULL
15
NULL
2