AdventureWorks
Sales.SalesTerritory Table
Description
Sales territory lookup table.
Properties
Creation Date08/01/2010 08:40
File GroupPRIMARY
Text File Group
System Object
Published for Replication
Rows10
Data Space Used8.00 KB
Index Space Used40.00 KB
Columns
 Column NameDescriptionDatatypeLengthAllow NullsDefaultFormula
Primary Key TerritoryIDPrimary key for SalesTerritory records.int4   
 NameSales territory descriptiondbo.Name50   
 CountryRegionCodeISO standard country or region code. Foreign key to CountryRegion.CountryRegionCode. nvarchar3   
 GroupGeographic area to which the sales territory belong.nvarchar50   
 SalesYTDSales in the territory year to date.money8 
((0.00))
 
 SalesLastYearSales in the territory the previous year.money8 
((0.00))
 
 CostYTDBusiness costs in the territory year to date.money8 
((0.00))
 
 CostLastYearBusiness costs in the territory the previous year.money8 
((0.00))
 
 rowguidROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.uniqueidentifier16 
(newid())
 
 ModifiedDateDate and time the record was last updated.datetime4 
(getdate())
 
Indexes
IndexDescriptionPrimaryUnique
AK_SalesTerritory_NameUnique nonclustered index. 
AK_SalesTerritory_rowguidUnique nonclustered index. Used to support replication samples. 
PK_SalesTerritory_TerritoryIDPrimary key (clustered) constraint
Check Constraints
NameDescriptionExpression
CK_SalesTerritory_CostLastYearCheck constraint [CostLastYear] >= (0.00)
([CostLastYear]>=(0.00))
CK_SalesTerritory_CostYTDCheck constraint [CostYTD] >= (0.00)
([CostYTD]>=(0.00))
CK_SalesTerritory_SalesLastYearCheck constraint [SalesLastYear] >= (0.00)
([SalesLastYear]>=(0.00))
CK_SalesTerritory_SalesYTDCheck constraint [SalesYTD] >= (0.00)
([SalesYTD]>=(0.00))
Relationships
RelationshipDescription
FK_Customer_SalesTerritory_TerritoryIDForeign key constraint referencing SalesTerritory.TerritoryID.
FK_SalesOrderHeader_SalesTerritory_TerritoryIDForeign key constraint referencing SalesTerritory.TerritoryID.
FK_SalesPerson_SalesTerritory_TerritoryIDForeign key constraint referencing SalesTerritory.TerritoryID.
FK_SalesTerritoryHistory_SalesTerritory_TerritoryIDForeign key constraint referencing SalesTerritory.TerritoryID.
FK_StateProvince_SalesTerritory_TerritoryIDForeign key constraint referencing SalesTerritory.TerritoryID.
Objects that depend on Sales.SalesTerritory
 Database ObjectObject TypeDescriptionDep Level
Person.Address tablePerson.AddressTableStreet address information for customers, employees, and vendors.2
Sales.Customer tableSales.CustomerTableCurrent customer information. Also see the Individual and Store tables.1
HumanResources.EmployeeAddress tableHumanResources.EmployeeAddressTableCross-reference table mapping employees to their address(es).3
iduSalesOrderDetail triggeriduSalesOrderDetailTriggerAFTER INSERT, DELETE, UPDATE trigger that inserts a row in the TransactionHistory table, updates ModifiedDate in SalesOrderDetail and updates the SalesOrderHeader.SubTotal column.3
Sales.Individual tableSales.IndividualTableDemographic data about customers that purchase Adventure Works products online.2
iStore triggeriStoreTriggerAFTER INSERT trigger inserting Store only if the Customer does not exist in the Individual table.3
iuIndividual triggeriuIndividualTriggerAFTER INSERT, UPDATE trigger inserting Individual only if the Customer does not exist in the Store table and setting the ModifiedDate column in the Individual table to the current date.3
Sales.SalesOrderDetail tableSales.SalesOrderDetailTableIndividual products associated with a specific sales order. See SalesOrderHeader.2
Sales.SalesOrderHeader tableSales.SalesOrderHeaderTableGeneral sales order information.1
Sales.SalesOrderHeaderSalesReason tableSales.SalesOrderHeaderSalesReasonTableCross-reference table mapping sales orders to sales reason codes.2
Sales.SalesPerson tableSales.SalesPersonTableSales representative current information.1
Sales.SalesPersonQuotaHistory tableSales.SalesPersonQuotaHistoryTableSales performance tracking.2
Sales.SalesTaxRate tableSales.SalesTaxRateTableTax rate lookup table.2
Sales.SalesTerritoryHistory tableSales.SalesTerritoryHistoryTableSales representative transfers to other sales territories.1
Person.StateProvince tablePerson.StateProvinceTableState and province lookup table.1
Sales.Store tableSales.StoreTableCustomers (resellers) of Adventure Works products.2
Sales.StoreContact tableSales.StoreContactTableCross-reference table mapping stores and their employees.3
dbo.ufnGetContactInformation functiondbo.ufnGetContactInformationUser Defined FunctionTable value function returning the first name, last name, job title and contact type for a given contact.3
uSalesOrderHeader triggeruSalesOrderHeaderTriggerAFTER UPDATE trigger that updates the RevisionNumber and ModifiedDate columns in the SalesOrderHeader table.Updates the SalesYTD column in the SalesPerson and SalesTerritory tables.2
HumanResources.vEmployee viewHumanResources.vEmployeeViewEmployee names and addresses.2
Purchasing.VendorAddress tablePurchasing.VendorAddressTableCross-reference mapping vendors and addresses.3
Sales.vIndividualCustomer viewSales.vIndividualCustomerViewIndividual customers (names and addresses) that purchase Adventure Works Cycles products online.2
Sales.vIndividualDemographics viewSales.vIndividualDemographicsViewDisplays the content from each element in the xml column Demographics for each customer in the Sales.Individual table.3
Sales.vSalesPerson viewSales.vSalesPersonViewSales representiatives (names and addresses) and their sales-related information.1
Sales.vSalesPersonSalesByFiscalYears viewSales.vSalesPersonSalesByFiscalYearsViewUses PIVOT to return aggregated sales information for each sales representative.1
Person.vStateProvinceCountryRegion viewPerson.vStateProvinceCountryRegionViewJoins StateProvince table with CountryRegion table.2
Sales.vStoreWithDemographics viewSales.vStoreWithDemographicsViewStores (names and addresses) that sell Adventure Works Cycles products to consumers.2
Purchasing.vVendor viewPurchasing.vVendorViewVendor (company) names and addresses and the names of vendor employees to contact.2
Objects that Sales.SalesTerritory depends on
 Database ObjectObject TypeDescriptionDep Level
dbo.Name datatypedbo.NameUser Defined Data Type 1
SQL
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
CREATE TABLE [Sales].[SalesTerritory](
	[TerritoryID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [dbo].[Name] NOT NULL,
	[CountryRegionCode] [nvarchar](3) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[Group] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[SalesYTD] [money] NOT NULL,
	[SalesLastYear] [money] NOT NULL,
	[CostYTD] [money] NOT NULL,
	[CostLastYear] [money] NOT NULL,
	[rowguid] [uniqueidentifier] ROWGUIDCOL  NOT NULL,
	[ModifiedDate] [datetime] NOT NULL,
 CONSTRAINT [PK_SalesTerritory_TerritoryID] PRIMARY KEY CLUSTERED 
(
	[TerritoryID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

ALTER TABLE [Sales].[SalesTerritory]  WITH CHECK ADD  CONSTRAINT [CK_SalesTerritory_CostLastYear] CHECK  (([CostLastYear]>=(0.00)))
ALTER TABLE [Sales].[SalesTerritory] CHECK CONSTRAINT [CK_SalesTerritory_CostLastYear]
ALTER TABLE [Sales].[SalesTerritory]  WITH CHECK ADD  CONSTRAINT [CK_SalesTerritory_CostYTD] CHECK  (([CostYTD]>=(0.00)))
ALTER TABLE [Sales].[SalesTerritory] CHECK CONSTRAINT [CK_SalesTerritory_CostYTD]
ALTER TABLE [Sales].[SalesTerritory]  WITH CHECK ADD  CONSTRAINT [CK_SalesTerritory_SalesLastYear] CHECK  (([SalesLastYear]>=(0.00)))
ALTER TABLE [Sales].[SalesTerritory] CHECK CONSTRAINT [CK_SalesTerritory_SalesLastYear]
ALTER TABLE [Sales].[SalesTerritory]  WITH CHECK ADD  CONSTRAINT [CK_SalesTerritory_SalesYTD] CHECK  (([SalesYTD]>=(0.00)))
ALTER TABLE [Sales].[SalesTerritory] CHECK CONSTRAINT [CK_SalesTerritory_SalesYTD]
ALTER TABLE [Sales].[SalesTerritory] ADD  CONSTRAINT [DF_SalesTerritory_SalesYTD]  DEFAULT ((0.00)) FOR [SalesYTD]
ALTER TABLE [Sales].[SalesTerritory] ADD  CONSTRAINT [DF_SalesTerritory_SalesLastYear]  DEFAULT ((0.00)) FOR [SalesLastYear]
ALTER TABLE [Sales].[SalesTerritory] ADD  CONSTRAINT [DF_SalesTerritory_CostYTD]  DEFAULT ((0.00)) FOR [CostYTD]
ALTER TABLE [Sales].[SalesTerritory] ADD  CONSTRAINT [DF_SalesTerritory_CostLastYear]  DEFAULT ((0.00)) FOR [CostLastYear]
ALTER TABLE [Sales].[SalesTerritory] ADD  CONSTRAINT [DF_SalesTerritory_rowguid]  DEFAULT (newid()) FOR [rowguid]
ALTER TABLE [Sales].[SalesTerritory] ADD  CONSTRAINT [DF_SalesTerritory_ModifiedDate]  DEFAULT (getdate()) FOR [ModifiedDate]
See Also

Related Objects

Sales Schema
AdventureWorks Database

 

 


© 2012 All Rights Reserved.

Send comments on this topic.