Northwind Database (Document! X Sample)
Production.Document Table
AdventureWorks Database > Production Schema : Production.Document Table
Description
Product maintenance documents.
Properties
Creation Date27/10/2017 14:33
File GroupPRIMARY
Text File GroupPRIMARY
System Object
Published for Replication
Rows13
Data Space Used336.00 KB
Index Space Used72.00 KB
Columns
 Column NameDescriptionDatatypeLengthAllow NullsDefaultFormula
Primary Key Primary key for Document records.UserDefined892   
 Depth in the document hierarchy.SmallInt2 
([DocumentNode].[GetLevel]())
 Title of the document.VarWChar50   
 Employee who controls the document. Foreign key to Employee.BusinessEntityIDInteger4   
 0 = This is a folder, 1 = This is a document.Boolean1 
((0))
 
 File name of the documentVarWChar400   
 File extension indicating the document type. For example, .doc or .txt.VarWChar8   
 Revision number of the document. WChar5   
 Engineering change approval number.Integer4 
((0))
 
 1 = Pending approval, 2 = Approved, 3 = ObsoleteUnsignedTinyInt1   
 Document abstract.LongVarWChar16  
 Complete document.LongVarBinary16  
 ROWGUIDCOL number uniquely identifying the record. Required for FileStream.GUID16 
(newid())
 
 Date and time the record was last updated.DBTimeStamp4 
(getdate())
 
Indexes
IndexDescriptionPrimaryUnique
Unique nonclustered index. 
Unique nonclustered index. Used to support FileStream. 
Unique nonclustered index.  
Primary key (clustered) constraint
  
Check Constraints
NameDescriptionExpression
Check constraint [Status] BETWEEN (1) AND (3)
([Status]>=(1) AND [Status]<=(3))
Relationships
RelationshipDescription
Foreign key constraint referencing Employee.BusinessEntityID.
Foreign key constraint referencing Document.DocumentNode.
Objects that depend on Production.Document
 Database ObjectObject TypeDescriptionDep Level
Production.ProductDocument tableProduction.ProductDocumentTableCross-reference table mapping products to related product documents.1
Objects that Production.Document depends on
 Database ObjectObject TypeDescriptionDep Level
Person.BusinessEntity tablePerson.BusinessEntityTableSource of the ID that connects vendors, customers, and employees with address and contact information.3
HumanResources.Employee tableHumanResources.EmployeeTableEmployee information such as salary, department, and title.1
dbo.Flag datatypedbo.FlagUser Defined Data Type 2
dbo.Name datatypedbo.NameUser Defined Data Type 3
dbo.NameStyle datatypedbo.NameStyleUser Defined Data Type 3
Person.Person tablePerson.PersonTableHuman beings involved with AdventureWorks: employees, customer contacts, and vendor contacts.2
SQL
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
CREATE TABLE [Production].[Document](
    [DocumentNode] [hierarchyid] NOT NULL,
    [DocumentLevel]  AS ([DocumentNode].[GetLevel]()),
    [Title] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [Owner] [int] NOT NULL,
    [FolderFlag] [bit] NOT NULL,
    [FileName] [nvarchar](400) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [FileExtension] [nvarchar](8) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [Revision] [nchar](5) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [ChangeNumber] [int] NOT NULL,
    [Status] [tinyint] NOT NULL,
    [DocumentSummary] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [Document] [varbinary](max) NULL,
    [rowguid] [uniqueidentifier] ROWGUIDCOL  NOT NULL,
    [ModifiedDate] [datetime] NOT NULL,
 CONSTRAINT [PK_Document_DocumentNode] PRIMARY KEY CLUSTERED 
(
    [DocumentNode] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
UNIQUE NONCLUSTERED 
(
    [rowguid] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

ALTER TABLE [Production].[Document] ADD  CONSTRAINT [DF_Document_FolderFlag]  DEFAULT ((0)) FOR [FolderFlag]
ALTER TABLE [Production].[Document] ADD  CONSTRAINT [DF_Document_ChangeNumber]  DEFAULT ((0)) FOR [ChangeNumber]
ALTER TABLE [Production].[Document] ADD  CONSTRAINT [DF_Document_rowguid]  DEFAULT (newid()) FOR [rowguid]
ALTER TABLE [Production].[Document] ADD  CONSTRAINT [DF_Document_ModifiedDate]  DEFAULT (getdate()) FOR [ModifiedDate]
ALTER TABLE [Production].[Document]  WITH CHECK ADD  CONSTRAINT [FK_Document_Employee_Owner] FOREIGN KEY([Owner])
REFERENCES [HumanResources].[Employee] ([BusinessEntityID])
ALTER TABLE [Production].[Document] CHECK CONSTRAINT [FK_Document_Employee_Owner]
ALTER TABLE [Production].[Document]  WITH CHECK ADD  CONSTRAINT [CK_Document_Status] CHECK  (([Status]>=(1) AND [Status]<=(3)))
ALTER TABLE [Production].[Document] CHECK CONSTRAINT [CK_Document_Status]
See Also

Related Objects

Production Schema
AdventureWorks Database