Northwind

Microsoft sample database14/07/2008
4.25 MB

Summary

Tables

Table: dbo.Categories

asdf<b>bold</b> text

Fields

Field name Data type Nullable Default value Field description
CategoryIDintCategories of Northwind products.
CategoryNamenvarchar (15) Name of food category.
DescriptionntextYesFull description of the category. Provide samples.
PictureimageYesA picture representing the food category.

Referencing tables

Table nameForeign keyPrimary key or unique constraint
dbo.ProductsFK_Products_CategoriesPK_Categories

Indices

Index nameColumn nameSort directionUniqueIndex type
CategoryNameCategoryNameASCNONCLUSTERED
PK_CategoriesCategoryIDASCYesCLUSTERED

Field extended properties:

Column nameExtended propertyValue
CategoryIDAuthorField level property

Object permissions

User / RoleSELECTINSERTUPDATEDELETEEXECUTEDRI
publicgrantgrantgrantgrantgrant

Extended properties

AuthorJohn Smith
CustomProperty1Sample value to test extended properties

Related objects

viewdbo.Alphabetical list of products
viewdbo.Product Sales for 1997
viewdbo.Products by Category
viewdbo.Sales by Category
stored proceduredbo.SalesByCategory

Table definition

CREATE TABLE [dbo.Categories] (
	[CategoryID] [int] IDENTITY (1, 1) NOT NULL ,
	[CategoryName] [nvarchar] (15) COLLATE Modern_Spanish_CI_AS NOT NULL ,
	[Description] [ntext] COLLATE Modern_Spanish_CI_AS NULL ,
	[Picture] [image] NULL ,
	CONSTRAINT [PK_Categories] PRIMARY KEY  CLUSTERED 
	(
		[CategoryID]
	)  ON [PRIMARY] 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO


Table: dbo.CustomerCustomerDemo

Test description

Fields

Field name Data type Nullable Default value Field description
CustomerIDnchar (5) 234
CustomerTypeIDnchar (10) 234

Foreign keys dependencies:

NameColumnReferenceForeign Key description
FK_CustomerCustomerDemo_CustomersCustomerIDPK_Customers (dbo.Customers)
FK_CustomerCustomerDemoCustomerTypeIDPK_CustomerDemographics (dbo.CustomerDemographics)

Indices

Index nameColumn nameSort directionUniqueIndex type
PK_CustomerCustomerDemoCustomerIDASCYesNONCLUSTERED
CustomerTypeIDASCYesNONCLUSTERED

Object permissions

User / RoleSELECTINSERTUPDATEDELETEEXECUTEDRI
publicgrantgrantgrantgrantgrant

Table definition

CREATE TABLE [dbo.CustomerCustomerDemo] (
	[CustomerID] [nchar] (5) COLLATE Modern_Spanish_CI_AS NOT NULL ,
	[CustomerTypeID] [nchar] (10) COLLATE Modern_Spanish_CI_AS NOT NULL ,
	CONSTRAINT [PK_CustomerCustomerDemo] PRIMARY KEY  NONCLUSTERED 
	(
		[CustomerID],
		[CustomerTypeID]
	)  ON [PRIMARY] ,
	CONSTRAINT [FK_CustomerCustomerDemo] FOREIGN KEY 
	(
		[CustomerTypeID]
	) REFERENCES [CustomerDemographics] (
		[CustomerTypeID]
	),
	CONSTRAINT [FK_CustomerCustomerDemo_Customers] FOREIGN KEY 
	(
		[CustomerID]
	) REFERENCES [Customers] (
		[CustomerID]
	)
) ON [PRIMARY]
GO


Table: dbo.CustomerDemographics

dfdf

Fields

Field name Data type Nullable Default value Field description
CustomerTypeIDnchar (10) 123465
CustomerDescntextYessdfg

Referencing tables

Table nameForeign keyPrimary key or unique constraint
dbo.CustomerCustomerDemoFK_CustomerCustomerDemoPK_CustomerDemographics

Indices

Index nameColumn nameSort directionUniqueIndex type
PK_CustomerDemographicsCustomerTypeIDASCYesNONCLUSTERED

Object permissions

User / RoleSELECTINSERTUPDATEDELETEEXECUTEDRI
publicgrantgrantgrantgrantgrant

Table definition

CREATE TABLE [dbo.CustomerDemographics] (
	[CustomerTypeID] [nchar] (10) COLLATE Modern_Spanish_CI_AS NOT NULL ,
	[CustomerDesc] [ntext] COLLATE Modern_Spanish_CI_AS NULL ,
	CONSTRAINT [PK_CustomerDemographics] PRIMARY KEY  NONCLUSTERED 
	(
		[CustomerTypeID]
	)  ON [PRIMARY] 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO


Table: dbo.Customers (go to dbdesc.com to register)

º

Fields

Field name Data type Nullable Default value Field description
CustomerIDnchar (5) Unique five-character code based on customer name.
CompanyNamenvarchar (40) sdfg
ContactNamenvarchar (30) Yessdg
ContactTitlenvarchar (30) Yessdfg
Addressnvarchar (60) YesStreet or post-office box.
Citynvarchar (15) Yes
Regionnvarchar (15) YesState or province.
PostalCodenvarchar (10) Yes
Countrynvarchar (15) Yes
Phonenvarchar (24) YesPhone number includes country code or area code.
Faxnvarchar (24) YesPhone number includes country code or area code.

Referencing tables

Table nameForeign keyPrimary key or unique constraint
dbo.CustomerCustomerDemoFK_CustomerCustomerDemo_CustomersPK_Customers
dbo.OrdersFK_Orders_CustomersPK_Customers

Indices

Index nameColumn nameSort directionUniqueIndex type
CityCityASCNONCLUSTERED
CompanyNameCompanyNameASCNONCLUSTERED
IX_CustomersCompanyNameASCNONCLUSTERED
PK_CustomersCustomerIDASCYesCLUSTERED
PostalCodePostalCodeASCNONCLUSTERED
RegionRegionASCNONCLUSTERED

Object permissions

User / RoleSELECTINSERTUPDATEDELETEEXECUTEDRI
publicgrantgrantgrantgrantgrant

Extended properties

AuthorJohn Smith
CustomProperty1Sample value to test extended properties

Related objects

viewdbo.Customer and Suppliers by City
stored proceduredbo.CustOrderHist
viewdbo.Invoices
viewdbo.Orders Qry
viewdbo.Quarterly Orders
viewdbo.Sales Totals by Amount

Table definition

CREATE TABLE [dbo.Customers] (
	[CustomerID] [nchar] (5) COLLATE Modern_Spanish_CI_AS NOT NULL ,
	[CompanyName] [nvarchar] (40) COLLATE Modern_Spanish_CI_AS NOT NULL ,
	[ContactName] [nvarchar] (30) COLLATE Modern_Spanish_CI_AS NULL ,
	[ContactTitle] [nvarchar] (30) COLLATE Modern_Spanish_CI_AS NULL ,
	[Address] [nvarchar] (60) COLLATE Modern_Spanish_CI_AS NULL ,
	[City] [nvarchar] (15) COLLATE Modern_Spanish_CI_AS NULL ,
	[Region] [nvarchar] (15) COLLATE Modern_Spanish_CI_AS NULL ,
	[PostalCode] [nvarchar] (10) COLLATE Modern_Spanish_CI_AS NULL ,
	[Country] [nvarchar] (15) COLLATE Modern_Spanish_CI_AS NULL ,
	[Phone] [nvarchar] (24) COLLATE Modern_Spanish_CI_AS NULL ,
	[Fax] [nvarchar] (24) COLLATE Modern_Spanish_CI_AS NULL ,
	CONSTRAINT [PK_Customers] PRIMARY KEY  CLUSTERED 
	(
		[CustomerID]
	)  ON [PRIMARY] 
) ON [PRIMARY]
GO


Table: dbo.Employees (go to dbdesc.com to register)

Employees' names, titles, and personal information.

Fields

Field name Data type Nullable Default value Field description
EmployeeIDintNumber automatically assigned to new employee.
LastNamenvarchar (20)
FirstNamenvarchar (10)
Titlenvarchar (30) YesEmployee's title.
TitleOfCourtesynvarchar (25) Yes
BirthDatedatetimeYes
HireDatedatetimeYes
Addressnvarchar (60) Yes Street or post-office box.
Citynvarchar (15) Yes
Regionnvarchar (15) YesStreet or post-office box.
PostalCodenvarchar (10) Yes
Countrynvarchar (15) Yes
HomePhonenvarchar (24) YesPhone number includes country code or area code.
Extensionnvarchar (4) Yes Internal telephone extension number.
PhotoimageYesPicture of employee.
NotesntextYesGeneral information about employee's background.
ReportsTointYes Employee's supervisor.
PhotoPathnvarchar (255) Yes

Foreign keys dependencies:

NameColumnReferenceForeign Key description
FK_Employees_EmployeesReportsToPK_Employees (dbo.Employees)

Referencing tables

Table nameForeign keyPrimary key or unique constraint
dbo.EmployeesFK_Employees_EmployeesPK_Employees
dbo.EmployeeTerritoriesFK_EmployeeTerritories_EmployeesPK_Employees
dbo.OrdersFK_Orders_EmployeesPK_Employees

Indices

Index nameColumn nameSort directionUniqueIndex type
LastNameLastNameASCNONCLUSTERED
PK_EmployeesEmployeeIDASCYesCLUSTERED
PostalCodeASCNONCLUSTERED

Check constraints

Check nameColumn nameCheck expresion
CK_BirthdateBirthDate([BirthDate] < getdate())

Object permissions

User / RoleSELECTINSERTUPDATEDELETEEXECUTEDRI
publicgrantgrantgrantgrantgrant

Related objects

stored proceduredbo.Employee Sales by Country
viewdbo.Invoices

Table definition

CREATE TABLE [dbo.Employees] (
	[EmployeeID] [int] IDENTITY (1, 1) NOT NULL ,
	[LastName] [nvarchar] (20) COLLATE Modern_Spanish_CI_AS NOT NULL ,
	[FirstName] [nvarchar] (10) COLLATE Modern_Spanish_CI_AS NOT NULL ,
	[Title] [nvarchar] (30) COLLATE Modern_Spanish_CI_AS NULL ,
	[TitleOfCourtesy] [nvarchar] (25) COLLATE Modern_Spanish_CI_AS NULL ,
	[BirthDate] [datetime] NULL ,
	[HireDate] [datetime] NULL ,
	[Address] [nvarchar] (60) COLLATE Modern_Spanish_CI_AS NULL ,
	[City] [nvarchar] (15) COLLATE Modern_Spanish_CI_AS NULL ,
	[Region] [nvarchar] (15) COLLATE Modern_Spanish_CI_AS NULL ,
	[PostalCode] [nvarchar] (10) COLLATE Modern_Spanish_CI_AS NULL ,
	[Country] [nvarchar] (15) COLLATE Modern_Spanish_CI_AS NULL ,
	[HomePhone] [nvarchar] (24) COLLATE Modern_Spanish_CI_AS NULL ,
	[Extension] [nvarchar] (4) COLLATE Modern_Spanish_CI_AS NULL ,
	[Photo] [image] NULL ,
	[Notes] [ntext] COLLATE Modern_Spanish_CI_AS NULL ,
	[ReportsTo] [int] NULL ,
	[PhotoPath] [nvarchar] (255) COLLATE Modern_Spanish_CI_AS NULL ,
	CONSTRAINT [PK_Employees] PRIMARY KEY  CLUSTERED 
	(
		[EmployeeID]
	)  ON [PRIMARY] ,
	CONSTRAINT [FK_Employees_Employees] FOREIGN KEY 
	(
		[ReportsTo]
	) REFERENCES [Employees] (
		[EmployeeID]
	),
	CONSTRAINT [CK_Birthdate] CHECK ([BirthDate] < getdate())
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO


Table: dbo.EmployeeTerritories (go to dbdesc.com to register)

Fields

Field name Data type Nullable Default value Field description
EmployeeIDint
TerritoryIDnvarchar (20)

Foreign keys dependencies:

NameColumnReferenceForeign Key description
FK_EmployeeTerritories_EmployeesEmployeeIDPK_Employees (dbo.Employees)
FK_EmployeeTerritories_TerritoriesTerritoryIDPK_Territories (dbo.Territories)

Indices

Index nameColumn nameSort directionUniqueIndex type
PK_EmployeeTerritoriesEmployeeIDASCYesNONCLUSTERED
TerritoryIDASCYesNONCLUSTERED

Object permissions

User / RoleSELECTINSERTUPDATEDELETEEXECUTEDRI
publicgrantgrantgrantgrantgrant

Table definition

CREATE TABLE [dbo.EmployeeTerritories] (
	[EmployeeID] [int] NOT NULL ,
	[TerritoryID] [nvarchar] (20) COLLATE Modern_Spanish_CI_AS NOT NULL ,
	CONSTRAINT [PK_EmployeeTerritories] PRIMARY KEY  NONCLUSTERED 
	(
		[EmployeeID],
		[TerritoryID]
	)  ON [PRIMARY] ,
	CONSTRAINT [FK_EmployeeTerritories_Employees] FOREIGN KEY 
	(
		[EmployeeID]
	) REFERENCES [Employees] (
		[EmployeeID]
	),
	CONSTRAINT [FK_EmployeeTerritories_Territories] FOREIGN KEY 
	(
		[TerritoryID]
	) REFERENCES [Territories] (
		[TerritoryID]
	)
) ON [PRIMARY]
GO


Table: dbo.Order Details (go to dbdesc.com to register)

Details on products, quantities, and prices for each order in the Orders table.

Fields

Field name Data type Nullable Default value Field description
OrderIDintSame as Order ID in Orders table.
ProductIDintSame as Product ID in Products table.
UnitPricemoney(0)
Quantitysmallint(1)
Discountreal(0)

Foreign keys dependencies:

NameColumnReferenceForeign Key description
FK_Order_Details_OrdersOrderIDPK_Orders (dbo.Orders)
FK_Order_Details_ProductsProductIDPK_Products (dbo.Products)

Indices

Index nameColumn nameSort directionUniqueIndex type
OrderIDOrderIDASCNONCLUSTERED
OrdersOrder_DetailsOrderIDASCNONCLUSTERED
PK_Order_DetailsOrderIDASCYesCLUSTERED
ProductIDASCYesCLUSTERED
ProductIDProductIDASCNONCLUSTERED
ProductsOrder_DetailsProductIDASCNONCLUSTERED

Check constraints

Check nameColumn nameCheck expresion
CK_DiscountDiscount([Discount] >= 0 and [Discount] <= 1)
CK_QuantityQuantity([Quantity] > 0)
CK_UnitPriceUnitPrice([UnitPrice] >= 0)

Object permissions

User / RoleSELECTINSERTUPDATEDELETEEXECUTEDRI
publicgrantgrantgrantgrantgrant

Related objects

stored proceduredbo.CustOrderHist
stored proceduredbo.CustOrdersDetail
viewdbo.Invoices
viewdbo.Order Details Extended
viewdbo.Order Subtotals
viewdbo.Product Sales for 1997
stored proceduredbo.SalesByCategory

Table definition

CREATE TABLE [dbo.Order Details] (
	[OrderID] [int] NOT NULL ,
	[ProductID] [int] NOT NULL ,
	[UnitPrice] [money] NOT NULL CONSTRAINT [DF_Order_Details_UnitPrice] DEFAULT (0),
	[Quantity] [smallint] NOT NULL CONSTRAINT [DF_Order_Details_Quantity] DEFAULT (1),
	[Discount] [real] NOT NULL CONSTRAINT [DF_Order_Details_Discount] DEFAULT (0),
	CONSTRAINT [PK_Order_Details] PRIMARY KEY  CLUSTERED 
	(
		[OrderID],
		[ProductID]
	)  ON [PRIMARY] ,
	CONSTRAINT [FK_Order_Details_Orders] FOREIGN KEY 
	(
		[OrderID]
	) REFERENCES [Orders] (
		[OrderID]
	),
	CONSTRAINT [FK_Order_Details_Products] FOREIGN KEY 
	(
		[ProductID]
	) REFERENCES [Products] (
		[ProductID]
	),
	CONSTRAINT [CK_Discount] CHECK ([Discount] >= 0 and [Discount] <= 1),
	CONSTRAINT [CK_Quantity] CHECK ([Quantity] > 0),
	CONSTRAINT [CK_UnitPrice] CHECK ([UnitPrice] >= 0)
) ON [PRIMARY]
GO


Table: dbo.Orders (go to dbdesc.com to register)

Customer name, order date, and freight charge for each order.

Fields

Field name Data type Nullable Default value Field description
OrderIDint
CustomerIDnchar (5) Yes
EmployeeIDintYesSame entry as in Employees table.
OrderDatedatetimeYes
RequiredDatedatetimeYes
ShippedDatedatetimeYes
ShipViaintYesSame as Shipper ID in Shippers table.
FreightmoneyYes(0)
ShipNamenvarchar (40) YesName of person or company to receive the shipment.
ShipAddressnvarchar (60) YesStreet address only -- no post-office box allowed.
ShipCitynvarchar (15) Yes
ShipRegionnvarchar (15) YesState or province.
ShipPostalCodenvarchar (10) Yes
ShipCountrynvarchar (15) Yes

Foreign keys dependencies:

NameColumnReferenceForeign Key description
FK_Orders_CustomersCustomerIDPK_Customers (dbo.Customers)
FK_Orders_EmployeesEmployeeIDPK_Employees (dbo.Employees)
FK_Orders_ShippersShipViaPK_Shippers (dbo.Shippers)

Referencing tables

Table nameForeign keyPrimary key or unique constraint
dbo.Order DetailsFK_Order_Details_OrdersPK_Orders

Indices

Index nameColumn nameSort directionUniqueIndex type
CustomerIDCustomerIDASCNONCLUSTERED
CustomersOrdersCustomerIDASCNONCLUSTERED
EmployeeIDEmployeeIDASCNONCLUSTERED
EmployeesOrdersEmployeeIDASCNONCLUSTERED
OrderDateOrderDateASCNONCLUSTERED
PK_OrdersOrderIDASCYesCLUSTERED
ShippedDateShippedDateASCNONCLUSTERED
ShippersOrdersShipViaASCNONCLUSTERED
ShipPostalCodeShipPostalCodeASCNONCLUSTERED

Field extended properties:

Column nameExtended propertyValue
OrderIDMS_DescriptionsUnique order number.
CustomerIDMS_Descriptions Same entry as in Customers table.

Object permissions

User / RoleSELECTINSERTUPDATEDELETEEXECUTEDRI
publicgrantgrantgrantgrantgrant

Related objects

stored proceduredbo.CustOrderHist
stored proceduredbo.CustOrdersOrders
stored proceduredbo.Employee Sales by Country
viewdbo.Invoices
viewdbo.Orders Qry
viewdbo.Product Sales for 1997
viewdbo.Quarterly Orders
viewdbo.Sales by Category
stored proceduredbo.Sales by Year
viewdbo.Sales Totals by Amount
stored proceduredbo.SalesByCategory
viewdbo.Summary of Sales by Quarter
viewdbo.Summary of Sales by Year

Table definition

CREATE TABLE [dbo.Orders] (
	[OrderID] [int] IDENTITY (1, 1) NOT NULL ,
	[CustomerID] [nchar] (5) COLLATE Modern_Spanish_CI_AS NULL ,
	[EmployeeID] [int] NULL ,
	[OrderDate] [datetime] NULL ,
	[RequiredDate] [datetime] NULL ,
	[ShippedDate] [datetime] NULL ,
	[ShipVia] [int] NULL ,
	[Freight] [money] NULL CONSTRAINT [DF_Orders_Freight] DEFAULT (0),
	[ShipName] [nvarchar] (40) COLLATE Modern_Spanish_CI_AS NULL ,
	[ShipAddress] [nvarchar] (60) COLLATE Modern_Spanish_CI_AS NULL ,
	[ShipCity] [nvarchar] (15) COLLATE Modern_Spanish_CI_AS NULL ,
	[ShipRegion] [nvarchar] (15) COLLATE Modern_Spanish_CI_AS NULL ,
	[ShipPostalCode] [nvarchar] (10) COLLATE Modern_Spanish_CI_AS NULL ,
	[ShipCountry] [nvarchar] (15) COLLATE Modern_Spanish_CI_AS NULL ,
	CONSTRAINT [PK_Orders] PRIMARY KEY  CLUSTERED 
	(
		[OrderID]
	)  ON [PRIMARY] ,
	CONSTRAINT [FK_Orders_Customers] FOREIGN KEY 
	(
		[CustomerID]
	) REFERENCES [Customers] (
		[CustomerID]
	),
	CONSTRAINT [FK_Orders_Employees] FOREIGN KEY 
	(
		[EmployeeID]
	) REFERENCES [Employees] (
		[EmployeeID]
	),
	CONSTRAINT [FK_Orders_Shippers] FOREIGN KEY 
	(
		[ShipVia]
	) REFERENCES [Shippers] (
		[ShipperID]
	)
) ON [PRIMARY]
GO


Table: dbo.Products (go to dbdesc.com to register)

Product names, suppliers, prices, and units in stock.

Fields

Field name Data type Nullable Default value Field description
ProductIDintNumber automatically assigned to new product.
ProductNamenvarchar (40)
SupplierIDintYesSame entry as in Suppliers table.
CategoryIDintYesSame entry as in Categories table.
QuantityPerUnitnvarchar (20) Yes(e.g., 24-count case, 1-liter bottle).
UnitPricemoneyYes(0)
UnitsInStocksmallintYes(0)
UnitsOnOrdersmallintYes(0)
ReorderLevelsmallintYes(0)Minimum units to maintain in stock.
Discontinuedbit(0)Yes means item is no longer available.

Foreign keys dependencies:

NameColumnReferenceForeign Key description
FK_Products_SuppliersSupplierIDPK_Suppliers (dbo.Suppliers)
FK_Products_CategoriesCategoryIDPK_Categories (dbo.Categories)

Referencing tables

Table nameForeign keyPrimary key or unique constraint
dbo.Order DetailsFK_Order_Details_ProductsPK_Products

Indices

Index nameColumn nameSort directionUniqueIndex type
CategoriesProductsCategoryIDASCNONCLUSTERED
CategoryIDCategoryIDASCNONCLUSTERED
PK_ProductsProductIDASCYesCLUSTERED
ProductNameProductNameASCNONCLUSTERED
SupplierIDSupplierIDASCNONCLUSTERED
SuppliersProductsSupplierIDASCNONCLUSTERED

Check constraints

Check nameColumn nameCheck expresion
CK_Products_UnitPriceUnitPrice([UnitPrice] >= 0)
CK_ReorderLevelReorderLevel([ReorderLevel] >= 0)
CK_UnitsInStockUnitsInStock([UnitsInStock] >= 0)
CK_UnitsOnOrderUnitsOnOrder([UnitsOnOrder] >= 0)

Object permissions

User / RoleSELECTINSERTUPDATEDELETEEXECUTEDRI
publicgrantgrantgrantgrantgrant

Related objects

viewdbo.Alphabetical list of products
viewdbo.Current Product List
stored proceduredbo.CustOrderHist
stored proceduredbo.CustOrdersDetail
viewdbo.Invoices
viewdbo.Order Details Extended
viewdbo.Product Sales for 1997
viewdbo.Products Above Average Price
viewdbo.Products by Category
viewdbo.Sales by Category
stored proceduredbo.SalesByCategory
stored proceduredbo.Ten Most Expensive Products

Table definition

CREATE TABLE [dbo.Products] (
	[ProductID] [int] IDENTITY (1, 1) NOT NULL ,
	[ProductName] [nvarchar] (40) COLLATE Modern_Spanish_CI_AS NOT NULL ,
	[SupplierID] [int] NULL ,
	[CategoryID] [int] NULL ,
	[QuantityPerUnit] [nvarchar] (20) COLLATE Modern_Spanish_CI_AS NULL ,
	[UnitPrice] [money] NULL CONSTRAINT [DF_Products_UnitPrice] DEFAULT (0),
	[UnitsInStock] [smallint] NULL CONSTRAINT [DF_Products_UnitsInStock] DEFAULT (0),
	[UnitsOnOrder] [smallint] NULL CONSTRAINT [DF_Products_UnitsOnOrder] DEFAULT (0),
	[ReorderLevel] [smallint] NULL CONSTRAINT [DF_Products_ReorderLevel] DEFAULT (0),
	[Discontinued] [bit] NOT NULL CONSTRAINT [DF_Products_Discontinued] DEFAULT (0),
	CONSTRAINT [PK_Products] PRIMARY KEY  CLUSTERED 
	(
		[ProductID]
	)  ON [PRIMARY] ,
	CONSTRAINT [FK_Products_Categories] FOREIGN KEY 
	(
		[CategoryID]
	) REFERENCES [Categories] (
		[CategoryID]
	),
	CONSTRAINT [FK_Products_Suppliers] FOREIGN KEY 
	(
		[SupplierID]
	) REFERENCES [Suppliers] (
		[SupplierID]
	),
	CONSTRAINT [CK_Products_UnitPrice] CHECK ([UnitPrice] >= 0),
	CONSTRAINT [CK_ReorderLevel] CHECK ([ReorderLevel] >= 0),
	CONSTRAINT [CK_UnitsInStock] CHECK ([UnitsInStock] >= 0),
	CONSTRAINT [CK_UnitsOnOrder] CHECK ([UnitsOnOrder] >= 0)
) ON [PRIMARY]
GO


Table: dbo.Region (go to dbdesc.com to register)

Sample comment add to test dbdesc This is the second line

Fields

Field name Data type Nullable Default value Field description
RegionIDint
RegionDescriptionnchar (50)

Referencing tables

Table nameForeign keyPrimary key or unique constraint
dbo.TerritoriesFK_Territories_RegionPK_Region

Indices

Index nameColumn nameSort directionUniqueIndex type
PK_RegionRegionIDASCYesNONCLUSTERED

Object permissions

User / RoleSELECTINSERTUPDATEDELETEEXECUTEDRI
publicgrantgrantgrantgrantgrant

Table definition

CREATE TABLE [dbo.Region] (
	[RegionID] [int] NOT NULL ,
	[RegionDescription] [nchar] (50) COLLATE Modern_Spanish_CI_AS NOT NULL ,
	CONSTRAINT [PK_Region] PRIMARY KEY  NONCLUSTERED 
	(
		[RegionID]
	)  ON [PRIMARY] 
) ON [PRIMARY]
GO


Table: dbo.Shippers (go to dbdesc.com to register)

Shippers' names and phone numbers.

Fields

Field name Data type Nullable Default value Field description
ShipperIDint Number automatically assigned to new shipper.
CompanyNamenvarchar (40) Name of shipping company.
Phonenvarchar (24) YesPhone number includes country code or area code.

Referencing tables

Table nameForeign keyPrimary key or unique constraint
dbo.OrdersFK_Orders_ShippersPK_Shippers

Indices

Index nameColumn nameSort directionUniqueIndex type
PK_ShippersShipperIDASCYesCLUSTERED

Related objects

viewdbo.Invoices

Table definition

CREATE TABLE [dbo.Shippers] (
	[ShipperID] [int] IDENTITY (1, 1) NOT NULL ,
	[CompanyName] [nvarchar] (40) COLLATE Modern_Spanish_CI_AS NOT NULL ,
	[Phone] [nvarchar] (24) COLLATE Modern_Spanish_CI_AS NULL ,
	CONSTRAINT [PK_Shippers] PRIMARY KEY  CLUSTERED 
	(
		[ShipperID]
	)  ON [PRIMARY] 
) ON [PRIMARY]
GO


Table: dbo.Suppliers (go to dbdesc.com to register)

Suppliers' names, addresses, phone numbers, and hyperlinks to home pages.

Fields

Field name Data type Nullable Default value Field description
SupplierIDintNumber automatically assigned to new supplier.
CompanyNamenvarchar (40)
ContactNamenvarchar (30) Yes
ContactTitlenvarchar (30) Yes
Addressnvarchar (60) YesStreet or post-office box.
Citynvarchar (15) Yes
Regionnvarchar (15) YesState or province.
PostalCodenvarchar (10) Yes
Countrynvarchar (15) Yes
Phonenvarchar (24) YesPhone number includes country code or area code.
Faxnvarchar (24) YesPhone number includes country code or area code.
HomePagentextYesSupplier's home page on World Wide Web.

Referencing tables

Table nameForeign keyPrimary key or unique constraint
dbo.ProductsFK_Products_SuppliersPK_Suppliers

Indices

Index nameColumn nameSort directionUniqueIndex type
CompanyNameASCNONCLUSTERED
PK_SuppliersSupplierIDASCYesCLUSTERED
PostalCodeASCNONCLUSTERED

Object permissions

User / RoleSELECTINSERTUPDATEDELETEEXECUTEDRI
publicgrantgrantgrantgrantgrant

Related objects

viewdbo.Customer and Suppliers by City

Table definition

CREATE TABLE [dbo.Suppliers] (
	[SupplierID] [int] IDENTITY (1, 1) NOT NULL ,
	[CompanyName] [nvarchar] (40) COLLATE Modern_Spanish_CI_AS NOT NULL ,
	[ContactName] [nvarchar] (30) COLLATE Modern_Spanish_CI_AS NULL ,
	[ContactTitle] [nvarchar] (30) COLLATE Modern_Spanish_CI_AS NULL ,
	[Address] [nvarchar] (60) COLLATE Modern_Spanish_CI_AS NULL ,
	[City] [nvarchar] (15) COLLATE Modern_Spanish_CI_AS NULL ,
	[Region] [nvarchar] (15) COLLATE Modern_Spanish_CI_AS NULL ,
	[PostalCode] [nvarchar] (10) COLLATE Modern_Spanish_CI_AS NULL ,
	[Country] [nvarchar] (15) COLLATE Modern_Spanish_CI_AS NULL ,
	[Phone] [nvarchar] (24) COLLATE Modern_Spanish_CI_AS NULL ,
	[Fax] [nvarchar] (24) COLLATE Modern_Spanish_CI_AS NULL ,
	[HomePage] [ntext] COLLATE Modern_Spanish_CI_AS NULL ,
	CONSTRAINT [PK_Suppliers] PRIMARY KEY  CLUSTERED 
	(
		[SupplierID]
	)  ON [PRIMARY] 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO


Table: dbo.Territories (go to dbdesc.com to register)

sdfsf

Fields

Field name Data type Nullable Default value Field description
TerritoryIDnvarchar (20) sdfg
TerritoryDescriptionnchar (50) sdfg
RegionIDintsdfg

Foreign keys dependencies:

NameColumnReferenceForeign Key description
FK_Territories_RegionRegionIDPK_Region (dbo.Region)

Referencing tables

Table nameForeign keyPrimary key or unique constraint
dbo.EmployeeTerritoriesFK_EmployeeTerritories_TerritoriesPK_Territories

Indices

Index nameColumn nameSort directionUniqueIndex type
PK_TerritoriesTerritoryIDASCYesNONCLUSTERED

Object permissions

User / RoleSELECTINSERTUPDATEDELETEEXECUTEDRI
publicgrantgrantgrantgrantgrant

Table definition

CREATE TABLE [dbo.Territories] (
	[TerritoryID] [nvarchar] (20) COLLATE Modern_Spanish_CI_AS NOT NULL ,
	[TerritoryDescription] [nchar] (50) COLLATE Modern_Spanish_CI_AS NOT NULL ,
	[RegionID] [int] NOT NULL ,
	CONSTRAINT [PK_Territories] PRIMARY KEY  NONCLUSTERED 
	(
		[TerritoryID]
	)  ON [PRIMARY] ,
	CONSTRAINT [FK_Territories_Region] FOREIGN KEY 
	(
		[RegionID]
	) REFERENCES [Region] (
		[RegionID]
	)
) ON [PRIMARY]
GO


Table: dbo.TestTable (go to dbdesc.com to register)

This is a test table 2

Fields

Field name Data type Nullable Default value Field description
TestCustomFieldTestType (20) Yessdcs

Table definition

CREATE TABLE [dbo.TestTable] (
	[TestCustomField] [TestType] NULL 
) ON [PRIMARY]
GO


Views

View: dbo.Alphabetical list of products

View name:dbo.Alphabetical list of products
Description:
Creation date:06 Ago 2000
Last altered date:06 Ago 2000

Fields

Source Field name Data type Nullable Field description
tabledbo.ProductsProductIDint
tabledbo.ProductsProductNamenvarchar (40)
tabledbo.ProductsSupplierIDintYes
tabledbo.ProductsCategoryIDintYes
tabledbo.ProductsQuantityPerUnitnvarchar (20) Yes
tabledbo.ProductsUnitPricemoneyYes
tabledbo.ProductsUnitsInStocksmallintYes
tabledbo.ProductsUnitsOnOrdersmallintYes
tabledbo.ProductsReorderLevelsmallintYes
tabledbo.ProductsDiscontinuedbit
tabledbo.CategoriesCategoryNamenvarchar (15)

View definition
create view "Alphabetical list of products" AS
SELECT Products.*, Categories.CategoryName
FROM Categories INNER JOIN Products ON Categories.CategoryID = Products.CategoryID
WHERE (((Products.Discontinued)=0))

Object permissions

User / RoleSELECTINSERTUPDATEDELETEEXECUTEDRI
publicgrantgrantgrantgrant

Related objects

tabledbo.Products
tabledbo.Categories

View: dbo.Category Sales for 1997

View name:dbo.Category Sales for 1997
Description:Totals product sales by category based on values returned by the Product Sales for 1997 query.
Creation date:06 Ago 2000
Last altered date:06 Ago 2000

Fields

Source Field name Data type Nullable Field description
viewdbo.Product Sales for 1997CategoryNamenvarchar (15) CatName
tableCategorySalesmoneyYesCatSales

View definition
create view "Category Sales for 1997" AS
SELECT "Product Sales for 1997".CategoryName, Sum("Product Sales for 1997".ProductSales) AS CategorySales
FROM "Product Sales for 1997"
GROUP BY "Product Sales for 1997".CategoryName

Object permissions

User / RoleSELECTINSERTUPDATEDELETEEXECUTEDRI
publicgrantgrantgrantgrant

Related objects

viewdbo.Product Sales for 1997

View: dbo.Current Product List

View name:dbo.Current Product List
Description:Filters records in Products table; query returns only products that are not discontinued.
Creation date:06 Ago 2000
Last altered date:06 Ago 2000

Fields

Source Field name Data type Nullable Field description
tabledbo.ProductsProductIDint
tabledbo.ProductsProductNamenvarchar (40)

View definition
create view "Current Product List" AS
SELECT Product_List.ProductID, Product_List.ProductName
FROM Products AS Product_List
WHERE (((Product_List.Discontinued)=0))
--ORDER BY Product_List.ProductName

Object permissions

User / RoleSELECTINSERTUPDATEDELETEEXECUTEDRI
publicgrantgrantgrantgrant

Related objects

tabledbo.Products

View: dbo.Customer and Suppliers by City

View name:dbo.Customer and Suppliers by City
Description:
Creation date:06 Ago 2000
Last altered date:06 Ago 2000

Fields

Source Field name Data type Nullable Field description
tabledbo.CustomersCitynvarchar (15) Yes
tabledbo.CustomersCompanyNamenvarchar (40)
tabledbo.CustomersContactNamenvarchar (30) Yes
tableRelationshipvarchar (9)

View definition
create view "Customer and Suppliers by City" AS
SELECT City, CompanyName, ContactName, 'Customers' AS Relationship 
FROM Customers
UNION SELECT City, CompanyName, ContactName, 'Suppliers'
FROM Suppliers
--ORDER BY City, CompanyName

Object permissions

User / RoleSELECTINSERTUPDATEDELETEEXECUTEDRI
publicgrantgrantgrantgrant

Related objects

tabledbo.Suppliers
tabledbo.Customers

View: dbo.Invoices

View name:dbo.Invoices
Description:(Criteria) Record source for Invoice report. Based on six tables. Includes expressions that concatenate first and last employee name and that use the CCur function to calculate extended price.
Creation date:06 Ago 2000
Last altered date:06 Ago 2000

Fields

Source Field name Data type Nullable Field description
tabledbo.OrdersShipNamenvarchar (40) YesName of the shipper
tabledbo.OrdersShipAddressnvarchar (60) Yes
tabledbo.OrdersShipCitynvarchar (15) Yes
tabledbo.OrdersShipRegionnvarchar (15) Yes
tabledbo.OrdersShipPostalCodenvarchar (10) Yes
tabledbo.OrdersShipCountrynvarchar (15) Yes
tabledbo.OrdersCustomerIDnchar (5) Yes
tableCustomerNamenvarchar (40)
tabledbo.CustomersAddressnvarchar (60) Yes
tabledbo.CustomersCitynvarchar (15) Yes
tabledbo.CustomersRegionnvarchar (15) Yes
tabledbo.CustomersPostalCodenvarchar (10) Yes
tabledbo.CustomersCountrynvarchar (15) Yes
tableSalespersonnvarchar (31)
tabledbo.OrdersOrderIDint
tabledbo.OrdersOrderDatedatetimeYes
tabledbo.OrdersRequiredDatedatetimeYes
tabledbo.OrdersShippedDatedatetimeYes
tableShipperNamenvarchar (40)
tabledbo.ProductsProductIDint
tabledbo.ProductsProductNamenvarchar (40)
tabledbo.Order DetailsUnitPricemoney
tabledbo.Order DetailsQuantitysmallint
tabledbo.Order DetailsDiscountreal
tableExtendedPricemoneyYes
tabledbo.OrdersFreightmoneyYes

View definition
create view Invoices AS
SELECT Orders.ShipName, Orders.ShipAddress, Orders.ShipCity, Orders.ShipRegion, Orders.ShipPostalCode, 
	Orders.ShipCountry, Orders.CustomerID, Customers.CompanyName AS CustomerName, Customers.Address, Customers.City, 
	Customers.Region, Customers.PostalCode, Customers.Country, 
	(FirstName + ' ' + LastName) AS Salesperson, 
	Orders.OrderID, Orders.OrderDate, Orders.RequiredDate, Orders.ShippedDate, Shippers.CompanyName As ShipperName, 
	"Order Details".ProductID, Products.ProductName, "Order Details".UnitPrice, "Order Details".Quantity, 
	"Order Details".Discount, 
	(CONVERT(money,("Order Details".UnitPrice*Quantity*(1-Discount)100))*100) AS ExtendedPrice, Orders.Freight
FROM 	Shippers INNER JOIN 
		(Products INNER JOIN 
			(
				(Employees INNER JOIN 
					(Customers INNER JOIN Orders ON Customers.CustomerID = Orders.CustomerID) 
				ON Employees.EmployeeID = Orders.EmployeeID) 
			INNER JOIN "Order Details" ON Orders.OrderID = "Order Details".OrderID) 
		ON Products.ProductID = "Order Details".ProductID) 
	ON Shippers.ShipperID = Orders.ShipVia

Object permissions

User / RoleSELECTINSERTUPDATEDELETEEXECUTEDRI
publicgrantgrantgrantgrant

Related objects

tabledbo.Customers
tabledbo.Shippers
tabledbo.Employees
tabledbo.Order Details
tabledbo.Products
tabledbo.Orders

View: dbo.Order Details Extended

View name:dbo.Order Details Extended
Description:Record source for several forms and reports. Uses CCur function to compute the ExtendedPrice for each item ordered.
Creation date:06 Ago 2000
Last altered date:06 Ago 2000

Fields

Source Field name Data type Nullable Field description
tabledbo.Order DetailsOrderIDint
tabledbo.ProductsProductIDint
tabledbo.ProductsProductNamenvarchar (40)
tabledbo.Order DetailsUnitPricemoney
tabledbo.Order DetailsQuantitysmallint
tabledbo.Order DetailsDiscountreal
tableExtendedPricemoneyYes

View definition
create view "Order Details Extended" AS
SELECT "Order Details".OrderID, "Order Details".ProductID, Products.ProductName, 
	"Order Details".UnitPrice, "Order Details".Quantity, "Order Details".Discount, 
	(CONVERT(money,("Order Details".UnitPrice*Quantity*(1-Discount)100))*100) AS ExtendedPrice
FROM Products INNER JOIN "Order Details" ON Products.ProductID = "Order Details".ProductID
--ORDER BY "Order Details".OrderID

Object permissions

<
User / RoleSELECTINSERTUPDATEDELETEEXECUTEDRI