Database reference - AdventureWorks

AdventureWorks -  tables -  [Production].[ProductInventory]

Description

Product inventory information. 

Table properties

namevalue
name[Production].[ProductInventory]
createdMar 19 2009 9:08PM
modifiedMar 19 2009 9:08PM 
ansi nullson 
quoted identifieron 
row count1,069
Size of data56 kb
Size of indexes16 kb
Maximum size of a single row73 bytes

Columns

columndatatypelengthbytesdefaultnullsPKFKUQcomputedcomment
ProductIDint104 no  composite PK  Product.ProductID      no  Product identification number. Foreign key to Product.ProductID. 
LocationIDsmallint52 no  composite PK  Location.LocationID      no  Inventory location identification number. Foreign key to Location.LocationID.  
Shelfnvarchar(10)1040 no      no  Storage compartment within an inventory location. 
Bintinyint31 no      no  Storage container on a shelf in an inventory location. 
Quantitysmallint52((0))no      no  Quantity of products in the inventory location. 
rowguiduniqueidentifier3616(newid())no      no  ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample. 
ModifiedDatedatetime238(getdate())no      no  Date and time the record was last updated. 

Indexes

namedescriptioncolumncomment
PK_ProductInventory_ProductID_LocationIDclustered, unique, primary key located on PRIMARYProductID, LocationIDClustered index created by a primary key constraint. 

References

name
Location
Product

Foreign key graph

LocationProductProductInventory

Foreign keys

namecolumnsforeign columnstypecomment
FK_ProductInventory_Location_LocationIDLocationIDLocation.LocationID   Foreign key constraint referencing Location.LocationID. 
FK_ProductInventory_Product_ProductIDProductIDProduct.ProductID   Foreign key constraint referencing Product.ProductID. 

Check constraints

namecolumncomment
CK_ProductInventory_ShelfShelf    Check constraint [Shelf] like '[A-Za-z]' OR [Shelf]='N/A' 
CK_ProductInventory_BinBin    Check constraint [Bin] BETWEEN (0) AND (100) 

Defaults

default namecolumncomment
DF_ProductInventory_QuantityQuantityDefault constraint value of 0 
DF_ProductInventory_rowguidrowguidDefault constraint value of NEWID() 
DF_ProductInventory_ModifiedDateModifiedDateDefault constraint value of GETDATE() 

Dependency graph

DF_ProductInventory_ModifiedDateDF_ProductInventory_QuantityDF_ProductInventory_rowguidProductInventoryCK_ProductInventory_BinCK_ProductInventory_ShelfufnGetStockPK_ProductInventory_ProductID_LocationID...

Objects that depend on [Production].[ProductInventory]

nameobject typelevel
ufnGetStockfunction1

Sample rows

ProductIDLocationIDShelfBinQuantityrowguidModifiedDate
408  47a24246-6c43-48eb-968f-025738a8a410  9/8/2004 12:00:00 AM 
324  d4544d7d-caf5-46b3-ab22-5718dcc26b5e  9/8/2004 12:00:00 AM 
50  353  bff7dc60-96a8-43ca-81a7-d6d2ed3000a8  9/8/2004 12:00:00 AM 
427  f407c07a-ca14-4684-a02c-608bd00c2233  9/8/2004 12:00:00 AM 
318  ca1ff2f4-48fb-4960-8d92-3940b633e4c1  9/8/2004 12:00:00 AM 
50  364  d38cfbee-6347-47b1-b033-0e278cca03e2  9/8/2004 12:00:00 AM 
585  e18a519b-fb5e-4051-874c-58cd58436c95  5/2/1998 12:00:00 AM 
443  3c860c96-15ff-4df4-91d7-b237ff64480f  5/2/1998 12:00:00 AM 
50  10  324  1339e5e3-1f8e-4b82-a447-a8666a264f0c  5/2/1998 12:00:00 AM 
512  6beaf0a0-971a-4ce1-96fe-692807d5dc00  9/8/2004 12:00:00 AM 

Code

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]  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]
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]

Powered by Yoyodyne © 1971