Difference between revisions of "Sales.Store (table)"

From dbscript Online Help
Jump to: navigation, search
 
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
Line 8: Line 8:
 
| '''Description
 
| '''Description
 
| Customers (resellers) of Adventure Works products.
 
| Customers (resellers) of Adventure Works products.
|-
 
 
|}
 
|}
 
  
 
=== Columns ===
 
=== Columns ===
Line 20: Line 18:
 
| '''Default
 
| '''Default
 
| '''Description
 
| '''Description
+
 
 
|- valign="top"
 
|- valign="top"
 
| CustomerID
 
| CustomerID
Line 64: Line 62:
 
| '''Primary Key
 
| '''Primary Key
 
| '''Columns
 
| '''Columns
|-
+
|- valign="top"
 
| PK_Store_CustomerID
 
| PK_Store_CustomerID
 
| CustomerID
 
| CustomerID
Line 75: Line 73:
 
| '''Type
 
| '''Type
 
| '''Columns
 
| '''Columns
+
 
|-
+
|- valign="top"
 
| AK_Store_rowguid
 
| AK_Store_rowguid
 
| Unique
 
| Unique
 
| rowguid
 
| rowguid
|-
+
|- valign="top"
 
| IX_Store_SalesPersonID
 
| IX_Store_SalesPersonID
 
|  
 
|  
 
| SalesPersonID
 
| SalesPersonID
|-
+
|- valign="top"
 
| PXML_Store_Demographics
 
| PXML_Store_Demographics
 
|  
 
|  
Line 96: 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 113: Line 111:
 
| '''Column
 
| '''Column
 
| '''Referencing Column
 
| '''Referencing Column
+
 
|-
+
|- valign="top"
 
| [[Sales.StoreContact_(table)|Sales.StoreContact]]
 
| [[Sales.StoreContact_(table)|Sales.StoreContact]]
 
| CustomerID
 
| CustomerID
Line 123: Line 121:
 
{| 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"
| '''Triggers
+
| '''Trigger
 
| '''Type
 
| '''Type
+
 
|-
+
|- valign="top"
 
| iStore
 
| iStore
 
| ON INSERT
 
| ON INSERT
 
|}
 
|}
  
Trigger iStore
+
==== Trigger iStore ====
 
<pre>
 
<pre>
 
CREATE TRIGGER [Sales].[iStore] ON [Sales].[Store]  
 
CREATE TRIGGER [Sales].[iStore] ON [Sales].[Store]  
Line 170: Line 168:
 
END;
 
END;
 
</pre>
 
</pre>
+
 
 
=== References ===
 
=== References ===
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
Line 181: Line 179:
 
| '''Child Object
 
| '''Child Object
  
|-
+
|- valign="top"
 
| Data Type
 
| Data Type
 
| Type
 
| Type
Line 188: Line 186:
 
|  
 
|  
 
|  
 
|  
|-
+
|- valign="top"
 
| Schema
 
| Schema
 
| Schema
 
| Schema
Line 195: Line 193:
 
|  
 
|  
 
|  
 
|  
|-
+
|- valign="top"
 
| Data Type
 
| Data Type
 
| XML Schema Collection
 
| XML Schema Collection
| [[Sales.StoreSurveySchemaCollection_(xml_schema_collection)|Sales.StoreSurveySchemaCollection]]
+
| [[Sales.StoreSurveySchemaCollection_(xml schema collection)|Sales.StoreSurveySchemaCollection]]
  
 
|  
 
|  
 
|  
 
|  
|-
+
|- valign="top"
 
| Select
 
| Select
 
| Table
 
| Table
Line 209: Line 207:
 
| Trigger
 
| Trigger
 
| iStore
 
| iStore
|-
+
|- valign="top"
 
| Execute
 
| Execute
 
| Procedure
 
| Procedure
Line 216: Line 214:
 
| Trigger
 
| Trigger
 
| iStore
 
| iStore
|-
+
|- valign="top"
 
| Execute
 
| Execute
 
| Procedure
 
| Procedure
Line 235: Line 233:
 
| '''Child Object
 
| '''Child Object
  
|-
+
|- valign="top"
 
| Select
 
| Select
 
| View
 
| View
Line 242: Line 240:
 
|  
 
|  
 
|  
 
|  
|-
+
|- valign="top"
 
| Select
 
| Select
 
| Table
 
| Table

Latest revision as of 23:17, 23 June 2010

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