Difference between revisions of "Sales.Store (table)"
| (4 intermediate revisions by the same user not shown) | |||
| Line 2: | Line 2: | ||
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse" | {| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse" | ||
| − | |- | + | |- valign="top" |
| '''Table | | '''Table | ||
| Sales.Store | | Sales.Store | ||
| − | |- | + | |- valign="top" |
| + | | '''Description | ||
| + | | Customers (resellers) of Adventure Works products. | ||
|} | |} | ||
| − | + | === Columns === | |
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse" | {| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse" | ||
|- style="background:silver" | |- style="background:silver" | ||
| Line 15: | Line 17: | ||
| '''Nullable | | '''Nullable | ||
| '''Default | | '''Default | ||
| − | | ''' | + | | '''Description |
| − | + | ||
| − | + | |- valign="top" | |
| − | |- | ||
| CustomerID | | CustomerID | ||
| int | | int | ||
| not null | | not null | ||
| | | | ||
| − | | | + | | Primary key. Foreign key to Customer.CustomerID. |
| − | + | |- valign="top" | |
| − | |- | ||
| Name | | Name | ||
| dbo.Name | | dbo.Name | ||
| not null | | not null | ||
| | | | ||
| − | | | + | | Name of the store. |
| − | + | |- valign="top" | |
| − | |- | ||
| SalesPersonID | | SalesPersonID | ||
| int | | int | ||
| null | | null | ||
| | | | ||
| − | | | + | | ID of the sales person assigned to the customer. Foreign key to SalesPerson.SalesPersonID. |
| − | + | |- valign="top" | |
| − | |- | ||
| Demographics | | Demographics | ||
| xml | | xml | ||
| null | | null | ||
| | | | ||
| − | | | + | | Demographic informationg about the store such as the number of employees, annual sales and store type. |
| − | + | |- valign="top" | |
| − | |- | ||
| rowguid | | rowguid | ||
| uniqueidentifier | | uniqueidentifier | ||
| not null | | not null | ||
| (newid()) | | (newid()) | ||
| − | | | + | | ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample. |
| − | + | |- valign="top" | |
| − | |- | ||
| ModifiedDate | | ModifiedDate | ||
| datetime | | datetime | ||
| not null | | not null | ||
| (getdate()) | | (getdate()) | ||
| + | | Date and time the record was last updated. | ||
| + | |} | ||
| + | |||
| + | === Primary Key === | ||
| + | {| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse" | ||
| + | |- style="background:silver" | ||
| + | | '''Primary Key | ||
| + | | '''Columns | ||
| + | |- valign="top" | ||
| + | | PK_Store_CustomerID | ||
| + | | CustomerID | ||
| + | |} | ||
| + | |||
| + | === Indexes === | ||
| + | {| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse" | ||
| + | |- style="background:silver" | ||
| + | | '''Index | ||
| + | | '''Type | ||
| + | | '''Columns | ||
| + | |||
| + | |- valign="top" | ||
| + | | AK_Store_rowguid | ||
| + | | Unique | ||
| + | | rowguid | ||
| + | |- valign="top" | ||
| + | | IX_Store_SalesPersonID | ||
| | | | ||
| + | | SalesPersonID | ||
| + | |- valign="top" | ||
| + | | PXML_Store_Demographics | ||
| | | | ||
| + | | Demographics | ||
|} | |} | ||
| − | + | === Foreign Keys === | |
| − | |||
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse" | {| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse" | ||
|- style="background:silver" | |- style="background:silver" | ||
| Line 69: | Line 94: | ||
| '''Column | | '''Column | ||
| '''Referenced Column | | '''Referenced Column | ||
| − | + | ||
| − | |- | + | |- valign="top" |
| [[Sales.Customer_(table)|Sales.Customer]] | | [[Sales.Customer_(table)|Sales.Customer]] | ||
| CustomerID | | CustomerID | ||
| CustomerID | | CustomerID | ||
| − | |- | + | |- valign="top" |
| [[Sales.SalesPerson_(table)|Sales.SalesPerson]] | | [[Sales.SalesPerson_(table)|Sales.SalesPerson]] | ||
| SalesPersonID | | SalesPersonID | ||
| Line 80: | Line 105: | ||
|} | |} | ||
| − | + | === Detail Tables === | |
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse" | {| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse" | ||
|- style="background:silver" | |- style="background:silver" | ||
| Line 86: | Line 111: | ||
| '''Column | | '''Column | ||
| '''Referencing Column | | '''Referencing Column | ||
| − | + | ||
| − | |- | + | |- valign="top" |
| [[Sales.StoreContact_(table)|Sales.StoreContact]] | | [[Sales.StoreContact_(table)|Sales.StoreContact]] | ||
| CustomerID | | CustomerID | ||
| Line 93: | Line 118: | ||
|} | |} | ||
| − | + | === Triggers === | |
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse" | {| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse" | ||
|- style="background:silver" | |- style="background:silver" | ||
| − | | ''' | + | | '''Trigger |
| '''Type | | '''Type | ||
| − | + | ||
| − | |- | + | |- valign="top" |
| iStore | | iStore | ||
| ON INSERT | | ON INSERT | ||
|} | |} | ||
| + | |||
| + | ==== Trigger iStore ==== | ||
| + | <pre> | ||
| + | CREATE TRIGGER [Sales].[iStore] ON [Sales].[Store] | ||
| + | AFTER INSERT AS | ||
| + | BEGIN | ||
| + | DECLARE @Count int; | ||
| + | |||
| + | SET @Count = @@ROWCOUNT; | ||
| + | IF @Count = 0 | ||
| + | RETURN; | ||
| + | |||
| + | SET NOCOUNT ON; | ||
| + | |||
| + | BEGIN TRY | ||
| + | -- Only allow the Customer to be a Store OR Individual | ||
| + | IF EXISTS (SELECT * FROM inserted INNER JOIN [Sales].[Individual] | ||
| + | ON inserted.[CustomerID] = [Sales].[Individual].[CustomerID]) | ||
| + | BEGIN | ||
| + | -- Rollback any active or uncommittable transactions | ||
| + | IF @@TRANCOUNT > 0 | ||
| + | BEGIN | ||
| + | ROLLBACK TRANSACTION; | ||
| + | END | ||
| + | END; | ||
| + | END TRY | ||
| + | BEGIN CATCH | ||
| + | EXECUTE [dbo].[uspPrintError]; | ||
| + | |||
| + | -- Rollback any active or uncommittable transactions before | ||
| + | -- inserting information in the ErrorLog | ||
| + | IF @@TRANCOUNT > 0 | ||
| + | BEGIN | ||
| + | ROLLBACK TRANSACTION; | ||
| + | END | ||
| + | |||
| + | EXECUTE [dbo].[uspLogError]; | ||
| + | END CATCH; | ||
| + | END; | ||
| + | </pre> | ||
| + | |||
| + | === References === | ||
| + | {| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse" | ||
| + | |- style="background:silver" | ||
| + | | '''Dependency Type | ||
| + | | '''Object Type | ||
| + | | '''Referenced Object | ||
| + | |||
| + | | '''Child Type | ||
| + | | '''Child Object | ||
| + | |||
| + | |- valign="top" | ||
| + | | Data Type | ||
| + | | Type | ||
| + | | [[dbo.Name_(type)|dbo.Name]] | ||
| + | |||
| + | | | ||
| + | | | ||
| + | |- valign="top" | ||
| + | | Schema | ||
| + | | Schema | ||
| + | | [[Sales_(schema)|Sales]] | ||
| + | |||
| + | | | ||
| + | | | ||
| + | |- valign="top" | ||
| + | | Data Type | ||
| + | | XML Schema Collection | ||
| + | | [[Sales.StoreSurveySchemaCollection_(xml schema collection)|Sales.StoreSurveySchemaCollection]] | ||
| + | |||
| + | | | ||
| + | | | ||
| + | |- valign="top" | ||
| + | | Select | ||
| + | | Table | ||
| + | | [[Sales.Individual_(table)|Sales.Individual]] | ||
| + | |||
| + | | Trigger | ||
| + | | iStore | ||
| + | |- valign="top" | ||
| + | | Execute | ||
| + | | Procedure | ||
| + | | [[dbo.uspLogError_(procedure)|dbo.uspLogError]] | ||
| + | |||
| + | | Trigger | ||
| + | | iStore | ||
| + | |- valign="top" | ||
| + | | Execute | ||
| + | | Procedure | ||
| + | | [[dbo.uspPrintError_(procedure)|dbo.uspPrintError]] | ||
| + | |||
| + | | Trigger | ||
| + | | iStore | ||
| + | |} | ||
| + | |||
| + | === Dependencies === | ||
| + | {| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse" | ||
| + | |- style="background:silver" | ||
| + | | '''Reference Type | ||
| + | | '''Object Type | ||
| + | | '''Referencing Object | ||
| + | |||
| + | | '''Child Type | ||
| + | | '''Child Object | ||
| + | |||
| + | |- valign="top" | ||
| + | | Select | ||
| + | | View | ||
| + | | [[Sales.vStoreWithDemographics_(view)|Sales.vStoreWithDemographics]] | ||
| + | |||
| + | | | ||
| + | | | ||
| + | |- valign="top" | ||
| + | | Select | ||
| + | | Table | ||
| + | | [[Sales.Individual_(table)|Sales.Individual]] | ||
| + | |||
| + | | Trigger | ||
| + | | iuIndividual | ||
| + | |} | ||
| + | |||
| + | |||
== automatically generated == | == automatically generated == | ||
| Line 110: | Line 257: | ||
| Sales.Store | | Sales.Store | ||
|- valign="top" | |- valign="top" | ||
| − | |||
| '''Description | | '''Description | ||
| Customers (resellers) of Adventure Works products. | | Customers (resellers) of Adventure Works products. | ||
|- | |- | ||
| − | |||
|} | |} | ||
| Line 209: | Line 354: | ||
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse" | {| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse" | ||
|- style="background:silver" | |- style="background:silver" | ||
| + | | '''Dependency Type | ||
| + | | '''Object Type | ||
| '''Referenced Object | | '''Referenced Object | ||
| − | | ''' | + | |
| − | | ''' | + | | '''Child Type |
| + | | '''Child Object | ||
|- | |- | ||
| + | | Data Type | ||
| + | | Type | ||
| [[dbo.Name_(type)|dbo.Name]] | | [[dbo.Name_(type)|dbo.Name]] | ||
| − | | | + | |
| − | | | + | | |
| + | | | ||
|- | |- | ||
| − | |||
| Schema | | Schema | ||
| Schema | | Schema | ||
| + | | [[Sales_(schema)|Sales]] | ||
| + | |||
| + | | | ||
| + | | | ||
|- | |- | ||
| + | | Data Type | ||
| + | | XML Schema Collection | ||
| [[Sales.StoreSurveySchemaCollection_(xml_schema_collection)|Sales.StoreSurveySchemaCollection]] | | [[Sales.StoreSurveySchemaCollection_(xml_schema_collection)|Sales.StoreSurveySchemaCollection]] | ||
| − | | | + | |
| − | | | + | | |
| + | | | ||
|- | |- | ||
| + | | Select | ||
| + | | Table | ||
| [[Sales.Individual_(table)|Sales.Individual]] | | [[Sales.Individual_(table)|Sales.Individual]] | ||
| − | + | ||
| − | |||
| Trigger | | Trigger | ||
| iStore | | iStore | ||
|- | |- | ||
| + | | Execute | ||
| + | | Procedure | ||
| [[dbo.uspLogError_(procedure)|dbo.uspLogError]] | | [[dbo.uspLogError_(procedure)|dbo.uspLogError]] | ||
| − | + | ||
| − | |||
| Trigger | | Trigger | ||
| iStore | | iStore | ||
|- | |- | ||
| + | | Execute | ||
| + | | Procedure | ||
| [[dbo.uspPrintError_(procedure)|dbo.uspPrintError]] | | [[dbo.uspPrintError_(procedure)|dbo.uspPrintError]] | ||
| − | + | ||
| − | |||
| Trigger | | Trigger | ||
| iStore | | iStore | ||
| Line 248: | Line 408: | ||
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse" | {| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse" | ||
|- style="background:silver" | |- style="background:silver" | ||
| + | | '''Reference Type | ||
| + | | '''Object Type | ||
| '''Referencing Object | | '''Referencing Object | ||
| − | | ''' | + | |
| − | | ''' | + | | '''Child Type |
| + | | '''Child Object | ||
|- | |- | ||
| + | | Select | ||
| + | | View | ||
| [[Sales.vStoreWithDemographics_(view)|Sales.vStoreWithDemographics]] | | [[Sales.vStoreWithDemographics_(view)|Sales.vStoreWithDemographics]] | ||
| − | | | + | |
| + | | | ||
| + | | | ||
| + | |- | ||
| Select | | Select | ||
| − | | | + | | Table |
| [[Sales.Individual_(table)|Sales.Individual]] | | [[Sales.Individual_(table)|Sales.Individual]] | ||
| − | + | ||
| − | |||
| Trigger | | Trigger | ||
| iuIndividual | | iuIndividual | ||
|} | |} | ||
Latest revision as of 23:17, 23 June 2010
Contents
wikibot[edit]
| Table | Sales.Store |
| Description | Customers (resellers) of Adventure Works products. |
Columns[edit]
| Column | Data Type | Nullable | Default | Description |
| CustomerID | int | not null | Primary key. Foreign key to Customer.CustomerID. | |
| Name | dbo.Name | not null | Name of the store. | |
| SalesPersonID | int | null | ID of the sales person assigned to the customer. Foreign key to SalesPerson.SalesPersonID. | |
| Demographics | xml | null | Demographic informationg about the store such as the number of employees, annual sales and store type. | |
| rowguid | uniqueidentifier | not null | (newid()) | ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample. |
| ModifiedDate | datetime | not null | (getdate()) | Date and time the record was last updated. |
Primary Key[edit]
| Primary Key | Columns |
| PK_Store_CustomerID | CustomerID |
Indexes[edit]
| Index | Type | Columns |
| AK_Store_rowguid | Unique | rowguid |
| IX_Store_SalesPersonID | SalesPersonID | |
| PXML_Store_Demographics | Demographics |
Foreign Keys[edit]
| Relation | Column | Referenced Column |
| Sales.Customer | CustomerID | CustomerID |
| Sales.SalesPerson | SalesPersonID | SalesPersonID |
Detail Tables[edit]
| Detail Table | Column | Referencing Column |
| Sales.StoreContact | CustomerID | CustomerID |
Triggers[edit]
| Trigger | Type |
| iStore | ON INSERT |
Trigger iStore[edit]
CREATE TRIGGER [Sales].[iStore] ON [Sales].[Store]
AFTER INSERT AS
BEGIN
DECLARE @Count int;
SET @Count = @@ROWCOUNT;
IF @Count = 0
RETURN;
SET NOCOUNT ON;
BEGIN TRY
-- Only allow the Customer to be a Store OR Individual
IF EXISTS (SELECT * FROM inserted INNER JOIN [Sales].[Individual]
ON inserted.[CustomerID] = [Sales].[Individual].[CustomerID])
BEGIN
-- Rollback any active or uncommittable transactions
IF @@TRANCOUNT > 0
BEGIN
ROLLBACK TRANSACTION;
END
END;
END TRY
BEGIN CATCH
EXECUTE [dbo].[uspPrintError];
-- Rollback any active or uncommittable transactions before
-- inserting information in the ErrorLog
IF @@TRANCOUNT > 0
BEGIN
ROLLBACK TRANSACTION;
END
EXECUTE [dbo].[uspLogError];
END CATCH;
END;
References[edit]
| Dependency Type | Object Type | Referenced Object | Child Type | Child Object |
| Data Type | Type | dbo.Name | ||
| Schema | Schema | Sales | ||
| Data Type | XML Schema Collection | Sales.StoreSurveySchemaCollection | ||
| Select | Table | Sales.Individual | Trigger | iStore |
| Execute | Procedure | dbo.uspLogError | Trigger | iStore |
| Execute | Procedure | dbo.uspPrintError | Trigger | iStore |
Dependencies[edit]
| Reference Type | Object Type | Referencing Object | Child Type | Child Object |
| Select | View | Sales.vStoreWithDemographics | ||
| Select | Table | Sales.Individual | Trigger | iuIndividual |
automatically generated[edit]
| Table | Sales.Store |
| Description | Customers (resellers) of Adventure Works products. |
| Column | Data Type | Nullable | Default | Description / PK / Index |
| CustomerID | int | not null | Primary key. Foreign key to Customer.CustomerID. PK_Store_CustomerID | |
| Name | Name | not null | Name of the store. | |
| SalesPersonID | int | null | ID of the sales person assigned to the customer. Foreign key to SalesPerson.SalesPersonID. IX_Store_SalesPersonID | |
| Demographics | XML | null | Demographic informationg about the store such as the number of employees, annual sales and store type. PXML_Store_Demographics | |
| rowguid | uniqueidentifier | not null | (NEWID()) | ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample. AK_Store_rowguid |
| ModifiedDate | datetime | not null | (GETDATE()) | Date and time the record was last updated. |
| Relation | Column | Referenced Column |
| Sales.Customer | CustomerID | CustomerID |
| Sales.SalesPerson | SalesPersonID | SalesPersonID |
| Detail Table | Column | Referencing Column |
| Sales.StoreContact | CustomerID | CustomerID |
| Triggers | Type |
| iStore | ON INSERT |
| Dependency Type | Object Type | Referenced Object | Child Type | Child Object |
| Data Type | Type | dbo.Name | ||
| Schema | Schema | Sales | ||
| Data Type | XML Schema Collection | Sales.StoreSurveySchemaCollection | ||
| Select | Table | Sales.Individual | Trigger | iStore |
| Execute | Procedure | dbo.uspLogError | Trigger | iStore |
| Execute | Procedure | dbo.uspPrintError | Trigger | iStore |
| Reference Type | Object Type | Referencing Object | Child Type | Child Object |
| Select | View | Sales.vStoreWithDemographics | ||
| Select | Table | Sales.Individual | Trigger | iuIndividual |