AdventureWorks
Sales.Store Table
Description
Customers (resellers) of Adventure Works products.
Properties
Creation Date08/01/2010 08:40
File GroupPRIMARY
Text File GroupPRIMARY
System Object
Published for Replication
Rows701
Data Space Used808.00 KB
Index Space Used80.00 KB
Columns
 Column NameDescriptionDatatypeLengthAllow NullsDefaultFormula
Primary Key CustomerIDPrimary key. Foreign key to Customer.CustomerID.int4   
 NameName of the store.dbo.Name50   
 SalesPersonIDID of the sales person assigned to the customer. Foreign key to SalesPerson.SalesPersonID.int4  
 DemographicsDemographic informationg about the store such as the number of employees, annual sales and store type.Sales.StoreSurveySchemaCollection16  
 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_Store_rowguidUnique nonclustered index. Used to support replication samples. 
IX_Store_SalesPersonIDNonclustered index.  
PK_Store_CustomerIDPrimary key (clustered) constraint
Triggers
TriggerDescription
iStoreAFTER INSERT trigger inserting Store only if the Customer does not exist in the Individual table.
Relationships
RelationshipDescription
FK_Store_Customer_CustomerIDForeign key constraint referencing Customer.CustomerID.
FK_Store_SalesPerson_SalesPersonIDForeign key constraint referencing SalesPerson.SalesPersonID
FK_StoreContact_Store_CustomerIDForeign key constraint referencing Store.CustomerID.
Objects that depend on Sales.Store
 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.1
iStore triggeriStoreTriggerAFTER INSERT trigger inserting Store only if the Customer does not exist in the Individual table.1
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.2
Sales.SalesOrderDetail tableSales.SalesOrderDetailTableIndividual products associated with a specific sales order. See SalesOrderHeader.2
Sales.StoreContact tableSales.StoreContactTableCross-reference table mapping stores and their employees.1
dbo.ufnGetContactInformation functiondbo.ufnGetContactInformationUser Defined FunctionTable value function returning the first name, last name, job title and contact type for a given contact.2
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.2
Sales.vStoreWithDemographics viewSales.vStoreWithDemographicsViewStores (names and addresses) that sell Adventure Works Cycles products to consumers.1
Objects that Sales.Store depends on
 Database ObjectObject TypeDescriptionDep Level
Sales.Customer tableSales.CustomerTableCurrent customer information. Also see the Individual and Store tables.1
HumanResources.Employee tableHumanResources.EmployeeTableEmployee information such as salary, department, and title.2
dbo.ErrorLog tabledbo.ErrorLogTableAudit table tracking errors in the the AdventureWorks database that are caught by the CATCH block of a TRY...CATCH construct. Data is inserted by stored procedure dbo.uspLogError when it is executed from inside the CATCH block of a TRY...CATCH construct.2
dbo.Flag datatypedbo.FlagUser Defined Data Type 3
Sales.Individual tableSales.IndividualTableDemographic data about customers that purchase Adventure Works products online.1
dbo.Name datatypedbo.NameUser Defined Data Type 1
Sales.SalesPerson tableSales.SalesPersonTableSales representative current information.1
Sales.SalesTerritory tableSales.SalesTerritoryTableSales territory lookup table.2
dbo.ufnLeadingZeros functiondbo.ufnLeadingZerosUser Defined FunctionScalar function used by the Sales.Customer table to help set the account number.2
dbo.uspLogError proceduredbo.uspLogErrorStored ProcedureLogs error information in the ErrorLog table about the error that caused execution to jump to the CATCH block of a TRY...CATCH construct. Should be executed from within the scope of a CATCH block otherwise it will return without inserting error information.1
dbo.uspPrintError proceduredbo.uspPrintErrorStored ProcedurePrints error information about the error that caused execution to jump to the CATCH block of a TRY...CATCH construct. Should be executed from within the scope of a CATCH block otherwise it will return without printing any error information.1
SQL
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
CREATE TABLE [Sales].[Store](
	[CustomerID] [int] NOT NULL,
	[Name] [dbo].[Name] NOT NULL,
	[SalesPersonID] [int] NULL,
	[Demographics] [xml](CONTENT [Sales].[StoreSurveySchemaCollection]) NULL,
	[rowguid] [uniqueidentifier] ROWGUIDCOL  NOT NULL,
	[ModifiedDate] [datetime] NOT NULL,
 CONSTRAINT [PK_Store_CustomerID] PRIMARY KEY CLUSTERED 
(
	[CustomerID] 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].[Store]  WITH CHECK ADD  CONSTRAINT [FK_Store_Customer_CustomerID] FOREIGN KEY([CustomerID])
REFERENCES [Customer] ([CustomerID])
ALTER TABLE [Sales].[Store] CHECK CONSTRAINT [FK_Store_Customer_CustomerID]
ALTER TABLE [Sales].[Store]  WITH CHECK ADD  CONSTRAINT [FK_Store_SalesPerson_SalesPersonID] FOREIGN KEY([SalesPersonID])
REFERENCES [SalesPerson] ([SalesPersonID])
ALTER TABLE [Sales].[Store] CHECK CONSTRAINT [FK_Store_SalesPerson_SalesPersonID]
ALTER TABLE [Sales].[Store] ADD  CONSTRAINT [DF_Store_rowguid]  DEFAULT (newid()) FOR [rowguid]
ALTER TABLE [Sales].[Store] ADD  CONSTRAINT [DF_Store_ModifiedDate]  DEFAULT (getdate()) FOR [ModifiedDate]
See Also

Related Objects

Sales Schema
AdventureWorks Database

 

 


© 2012 All Rights Reserved.

Send comments on this topic.