AdventureWorks
Sales.SalesPerson Table
Description
Sales representative current information.
Properties
Creation Date08/01/2010 08:40
File GroupPRIMARY
Text File Group
System Object
Published for Replication
Rows17
Data Space Used8.00 KB
Index Space Used24.00 KB
Columns
 Column NameDescriptionDatatypeLengthAllow NullsDefaultFormula
Primary Key SalesPersonIDPrimary key for SalesPerson records.int4   
 TerritoryIDTerritory currently assigned to. Foreign key to SalesTerritory.SalesTerritoryID.int4  
 SalesQuotaProjected yearly sales.money8  
 BonusBonus due if quota is met.money8 
((0.00))
 
 CommissionPctCommision percent received per sale.smallmoney8 
((0.00))
 
 SalesYTDSales total year to date.money8 
((0.00))
 
 SalesLastYearSales total of 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_SalesPerson_rowguidUnique nonclustered index. Used to support replication samples. 
PK_SalesPerson_SalesPersonIDPrimary key (clustered) constraint
Check Constraints
NameDescriptionExpression
CK_SalesPerson_BonusCheck constraint [Bonus] >= (0.00)
([Bonus]>=(0.00))
CK_SalesPerson_CommissionPctCheck constraint [CommissionPct] >= (0.00)
([CommissionPct]>=(0.00))
CK_SalesPerson_SalesLastYearCheck constraint [SalesLastYear] >= (0.00)
([SalesLastYear]>=(0.00))
CK_SalesPerson_SalesQuotaCheck constraint [SalesQuota] > (0.00)
([SalesQuota]>(0.00))
CK_SalesPerson_SalesYTDCheck constraint [SalesYTD] >= (0.00)
([SalesYTD]>=(0.00))
Relationships
RelationshipDescription
FK_SalesOrderHeader_SalesPerson_SalesPersonIDForeign key constraint referencing SalesPerson.SalesPersonID.
FK_SalesPerson_Employee_SalesPersonIDForeign key constraint referencing Employee.EmployeeID.
FK_SalesPerson_SalesTerritory_TerritoryIDForeign key constraint referencing SalesTerritory.TerritoryID.
FK_SalesPersonQuotaHistory_SalesPerson_SalesPersonIDForeign key constraint referencing SalesPerson.SalesPersonID.
FK_SalesTerritoryHistory_SalesPerson_SalesPersonIDForeign key constraint referencing SalesPerson.SalesPersonID.
FK_Store_SalesPerson_SalesPersonIDForeign key constraint referencing SalesPerson.SalesPersonID
Objects that depend on Sales.SalesPerson
 Database ObjectObject TypeDescriptionDep Level
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.2
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.SalesPersonQuotaHistory tableSales.SalesPersonQuotaHistoryTableSales performance tracking.1
Sales.SalesTerritoryHistory tableSales.SalesTerritoryHistoryTableSales representative transfers to other sales territories.1
Sales.Store tableSales.StoreTableCustomers (resellers) of Adventure Works products.1
Sales.StoreContact tableSales.StoreContactTableCross-reference table mapping stores and their employees.2
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
Sales.vIndividualCustomer viewSales.vIndividualCustomerViewIndividual customers (names and addresses) that purchase Adventure Works Cycles products online.3
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
Sales.vStoreWithDemographics viewSales.vStoreWithDemographicsViewStores (names and addresses) that sell Adventure Works Cycles products to consumers.2
Objects that Sales.SalesPerson depends on
 Database ObjectObject TypeDescriptionDep Level
Person.Contact tablePerson.ContactTableNames of each employee, customer contact, and vendor contact.2
HumanResources.Employee tableHumanResources.EmployeeTableEmployee information such as salary, department, and title.1
dbo.Flag datatypedbo.FlagUser Defined Data Type 2
dbo.NameStyle datatypedbo.NameStyleUser Defined Data Type 3
dbo.Phone datatypedbo.PhoneUser Defined Data Type 3
Sales.SalesTerritory tableSales.SalesTerritoryTableSales territory lookup table.1
SQL
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
CREATE TABLE [Sales].[SalesPerson](
	[SalesPersonID] [int] NOT NULL,
	[TerritoryID] [int] NULL,
	[SalesQuota] [money] NULL,
	[Bonus] [money] NOT NULL,
	[CommissionPct] [smallmoney] NOT NULL,
	[SalesYTD] [money] NOT NULL,
	[SalesLastYear] [money] NOT NULL,
	[rowguid] [uniqueidentifier] ROWGUIDCOL  NOT NULL,
	[ModifiedDate] [datetime] NOT NULL,
 CONSTRAINT [PK_SalesPerson_SalesPersonID] PRIMARY KEY CLUSTERED 
(
	[SalesPersonID] 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].[SalesPerson]  WITH CHECK ADD  CONSTRAINT [FK_SalesPerson_Employee_SalesPersonID] FOREIGN KEY([SalesPersonID])
REFERENCES [Employee] ([EmployeeID])
ALTER TABLE [Sales].[SalesPerson] CHECK CONSTRAINT [FK_SalesPerson_Employee_SalesPersonID]
ALTER TABLE [Sales].[SalesPerson]  WITH CHECK ADD  CONSTRAINT [FK_SalesPerson_SalesTerritory_TerritoryID] FOREIGN KEY([TerritoryID])
REFERENCES [SalesTerritory] ([TerritoryID])
ALTER TABLE [Sales].[SalesPerson] CHECK CONSTRAINT [FK_SalesPerson_SalesTerritory_TerritoryID]
ALTER TABLE [Sales].[SalesPerson]  WITH CHECK ADD  CONSTRAINT [CK_SalesPerson_Bonus] CHECK  (([Bonus]>=(0.00)))
ALTER TABLE [Sales].[SalesPerson] CHECK CONSTRAINT [CK_SalesPerson_Bonus]
ALTER TABLE [Sales].[SalesPerson]  WITH CHECK ADD  CONSTRAINT [CK_SalesPerson_CommissionPct] CHECK  (([CommissionPct]>=(0.00)))
ALTER TABLE [Sales].[SalesPerson] CHECK CONSTRAINT [CK_SalesPerson_CommissionPct]
ALTER TABLE [Sales].[SalesPerson]  WITH CHECK ADD  CONSTRAINT [CK_SalesPerson_SalesLastYear] CHECK  (([SalesLastYear]>=(0.00)))
ALTER TABLE [Sales].[SalesPerson] CHECK CONSTRAINT [CK_SalesPerson_SalesLastYear]
ALTER TABLE [Sales].[SalesPerson]  WITH CHECK ADD  CONSTRAINT [CK_SalesPerson_SalesQuota] CHECK  (([SalesQuota]>(0.00)))
ALTER TABLE [Sales].[SalesPerson] CHECK CONSTRAINT [CK_SalesPerson_SalesQuota]
ALTER TABLE [Sales].[SalesPerson]  WITH CHECK ADD  CONSTRAINT [CK_SalesPerson_SalesYTD] CHECK  (([SalesYTD]>=(0.00)))
ALTER TABLE [Sales].[SalesPerson] CHECK CONSTRAINT [CK_SalesPerson_SalesYTD]
ALTER TABLE [Sales].[SalesPerson] ADD  CONSTRAINT [DF_SalesPerson_Bonus]  DEFAULT ((0.00)) FOR [Bonus]
ALTER TABLE [Sales].[SalesPerson] ADD  CONSTRAINT [DF_SalesPerson_CommissionPct]  DEFAULT ((0.00)) FOR [CommissionPct]
ALTER TABLE [Sales].[SalesPerson] ADD  CONSTRAINT [DF_SalesPerson_SalesYTD]  DEFAULT ((0.00)) FOR [SalesYTD]
ALTER TABLE [Sales].[SalesPerson] ADD  CONSTRAINT [DF_SalesPerson_SalesLastYear]  DEFAULT ((0.00)) FOR [SalesLastYear]
ALTER TABLE [Sales].[SalesPerson] ADD  CONSTRAINT [DF_SalesPerson_rowguid]  DEFAULT (newid()) FOR [rowguid]
ALTER TABLE [Sales].[SalesPerson] ADD  CONSTRAINT [DF_SalesPerson_ModifiedDate]  DEFAULT (getdate()) FOR [ModifiedDate]
See Also

Related Objects

Sales Schema
AdventureWorks Database

 

 


© 2012 All Rights Reserved.

Send comments on this topic.