Northwind Database (Document! X Sample)
AdventureWorks Database / Production Schema / Production.ProductInventory Table
In This Topic
    Production.ProductInventory Table
    In This Topic
    Description
    Product inventory information.
    Properties
    Creation Date27/10/2017 14:33
    File GroupPRIMARY
    Text File Group
    System Object
    Published for Replication
    Rows1069
    Data Space Used56.00 KB
    Index Space Used16.00 KB
    Columns
     Column NameDescriptionDatatypeLengthAllow NullsDefaultFormula
    Primary Key Product identification number. Foreign key to Product.ProductID.Integer4   
    Primary Key Inventory location identification number. Foreign key to Location.LocationID. SmallInt2   
     Storage compartment within an inventory location.VarWChar10   
     Storage container on a shelf in an inventory location.UnsignedTinyInt1   
     Quantity of products in the inventory location.SmallInt2 
    ((0))
     
     ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.GUID16 
    (newid())
     
     Date and time the record was last updated.DBTimeStamp4 
    (getdate())
     
    Indexes
    IndexDescriptionPrimaryUnique
    Primary key (clustered) constraint
    Check Constraints
    NameDescriptionExpression
    Check constraint [Bin] BETWEEN (0) AND (100)
    ([Bin]>=(0) AND [Bin]<=(100))
    Check constraint [Shelf] like '[A-Za-z]' OR [Shelf]='N/A'
    ([Shelf] like '[A-Za-z]' OR [Shelf]='N/A')
    Relationships
    RelationshipDescription
    Foreign key constraint referencing Location.LocationID.
    Foreign key constraint referencing Product.ProductID.
    Objects that depend on Production.ProductInventory
     Database ObjectObject TypeDescriptionDep Level
    dbo.ufnGetStock functiondbo.ufnGetStockUser Defined FunctionScalar function returning the quantity of inventory in LocationID 6 (Miscellaneous Storage)for a specified ProductID.3
    Objects that Production.ProductInventory depends on
     Database ObjectObject TypeDescriptionDep Level
    dbo.Flag datatypedbo.FlagUser Defined Data Type 4
    Production.Location tableProduction.LocationTableProduct inventory and manufacturing locations.1
    dbo.Name datatypedbo.NameUser Defined Data Type 2
    Production.Product tableProduction.ProductTableProducts sold or used in the manfacturing of sold products.1
    Production.ProductCategory tableProduction.ProductCategoryTableHigh-level product categorization.3
    Production.ProductModel tableProduction.ProductModelTableProduct model classification.2
    Production.ProductSubcategory tableProduction.ProductSubcategoryTableProduct subcategories. See ProductCategory table.2
    Production.UnitMeasure tableProduction.UnitMeasureTableUnit of measure lookup table.2
    SQL
    SET ANSI_NULLS ON
    SET QUOTED_IDENTIFIER ON
    CREATE TABLE [Production].[ProductInventory](
        [ProductID] [int] NOT NULL,
        [LocationID] [smallint] NOT NULL,
        [Shelf] [nvarchar](10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
        [Bin] [tinyint] NOT NULL,
        [Quantity] [smallint] NOT NULL,
        [rowguid] [uniqueidentifier] ROWGUIDCOL  NOT NULL,
        [ModifiedDate] [datetime] NOT NULL,
     CONSTRAINT [PK_ProductInventory_ProductID_LocationID] PRIMARY KEY CLUSTERED 
    (
        [ProductID] ASC,
        [LocationID] 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 [Production].[ProductInventory] ADD  CONSTRAINT [DF_ProductInventory_Quantity]  DEFAULT ((0)) FOR [Quantity]
    ALTER TABLE [Production].[ProductInventory] ADD  CONSTRAINT [DF_ProductInventory_rowguid]  DEFAULT (newid()) FOR [rowguid]
    ALTER TABLE [Production].[ProductInventory] ADD  CONSTRAINT [DF_ProductInventory_ModifiedDate]  DEFAULT (getdate()) FOR [ModifiedDate]
    ALTER TABLE [Production].[ProductInventory]  WITH CHECK ADD  CONSTRAINT [FK_ProductInventory_Location_LocationID] FOREIGN KEY([LocationID])
    REFERENCES [Production].[Location] ([LocationID])
    ALTER TABLE [Production].[ProductInventory] CHECK CONSTRAINT [FK_ProductInventory_Location_LocationID]
    ALTER TABLE [Production].[ProductInventory]  WITH CHECK ADD  CONSTRAINT [FK_ProductInventory_Product_ProductID] FOREIGN KEY([ProductID])
    REFERENCES [Production].[Product] ([ProductID])
    ALTER TABLE [Production].[ProductInventory] CHECK CONSTRAINT [FK_ProductInventory_Product_ProductID]
    ALTER TABLE [Production].[ProductInventory]  WITH CHECK ADD  CONSTRAINT [CK_ProductInventory_Bin] CHECK  (([Bin]>=(0) AND [Bin]<=(100)))
    ALTER TABLE [Production].[ProductInventory] CHECK CONSTRAINT [CK_ProductInventory_Bin]
    ALTER TABLE [Production].[ProductInventory]  WITH CHECK ADD  CONSTRAINT [CK_ProductInventory_Shelf] CHECK  (([Shelf] like '[A-Za-z]' OR [Shelf]='N/A'))
    ALTER TABLE [Production].[ProductInventory] CHECK CONSTRAINT [CK_ProductInventory_Shelf]
    See Also