ErdDocs

Example schemas / AdventureWorks Database

AdventureWorks Database ER diagram

What is the AdventureWorks database?

The AdventureWorks database is Microsoft’s sample OLTP database for SQL Server. Its 68 tables sit in five schemas: Person, HumanResources, Production, Purchasing and Sales. They model Adventure Works Cycles, a fictional company that makes bicycles and sells them online and through stores. It is the sample that looks like a real company. It has a shared identity table behind people, stores and vendors, a bill of materials, price histories, and a sales order split into header and detail. Microsoft itself describes nearly every column.

Below, ErdDocs draws this schema from its SQL, every table and every relation. The Data Dictionary tab has the printable reference, complete and free on this page. The SQL is further down.

Your schema

Hover a table to light up its relations, and click to pin them.

What each table does

  • BusinessEntityMicrosoft’s words: “source of the ID that connects vendors, customers, and employees with address and contact information.” Person, Store and Vendor all take their key from here.
  • PersonEvery human being in the model: employees, customer contacts and vendor contacts. PersonType tells them apart.
  • EmployeeAn employee is a Person with a job. Same BusinessEntityID, plus title, hire date and an OrganizationNode position in the org tree.
  • CustomerA customer is a Person, a Store, or a person buying for a store. PersonID and StoreID are both nullable.
  • SalesOrderHeader / SalesOrderDetailThe order and its lines. The header points at Address twice, once to bill and once to ship.
  • ProductThe catalog, with subcategory, model, unit measures and the make-or-buy flag.
  • BillOfMaterialsWhich components go into which assembly. It is Product referencing Product, twice.
  • ProductListPriceHistory / ProductCostHistoryPrices over time, keyed by product and start date, so an old order can be priced as it was.
  • Vendor / PurchaseOrderHeaderThe buying side: suppliers and the purchase orders sent to them, mirroring sales.
  • WorkOrderManufacturing: how many of a product were built and how many scrapped, and why.

Design decisions worth copying

  • BusinessEntity is a supertype. Person, Store and Vendor carry no key of their own. Their primary key is a BusinessEntityID that is also a foreign key, so one Address and one contact list serve all three. It is the classic answer to “a customer can be a person or a company”, and it costs a join on every lookup.
  • SalesOrderHeader references Address twice: BillToAddressID and ShipToAddressID. One order with two places gets two foreign keys into one table. The role lives in the prefix, and only the declared keys say that both columns point at the same table.
  • Prices live in history tables keyed by product and start date, not only on Product. ListPrice on Product is today’s price; ProductListPriceHistory is what makes last year’s invoice reproducible. The same pattern recurs for cost, pay rate and department transfers.
  • Microsoft documents almost every column inside the database as an MS_Description extended property. Those notes fill the data dictionary on this page, because documentation stored next to the schema travels with every copy of it.

The SQL

PostgreSQL dialect. Paste it into the tool above (it is already there), into your own database, or into a migration. You are free to copy it.

CREATE SCHEMA "Person";
CREATE SCHEMA "Production";
CREATE SCHEMA "Sales";
CREATE SCHEMA "HumanResources";
CREATE SCHEMA "Purchasing";

CREATE TABLE "Person"."Address" (
    "AddressID" integer,
    "AddressLine1" varchar(60) NOT NULL,
    "AddressLine2" varchar(60),
    "City" varchar(30) NOT NULL,
    "StateProvinceID" integer NOT NULL,
    "PostalCode" varchar(15) NOT NULL,
    "SpatialLocation" text,
    "rowguid" uuid NOT NULL DEFAULT gen_random_uuid(),
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("AddressID")
);
CREATE TABLE "Person"."AddressType" (
    "AddressTypeID" integer,
    "Name" varchar(50) NOT NULL,
    "rowguid" uuid NOT NULL DEFAULT gen_random_uuid(),
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("AddressTypeID")
);
CREATE TABLE "Production"."BillOfMaterials" (
    "BillOfMaterialsID" integer,
    "ProductAssemblyID" integer,
    "ComponentID" integer NOT NULL,
    "StartDate" timestamp NOT NULL DEFAULT now(),
    "EndDate" timestamp,
    "UnitMeasureCode" char(3) NOT NULL,
    "BOMLevel" smallint NOT NULL,
    "PerAssemblyQty" numeric(8,2) NOT NULL DEFAULT 1.00,
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("BillOfMaterialsID")
);
CREATE TABLE "Person"."BusinessEntity" (
    "BusinessEntityID" integer,
    "rowguid" uuid NOT NULL DEFAULT gen_random_uuid(),
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("BusinessEntityID")
);
CREATE TABLE "Person"."BusinessEntityAddress" (
    "BusinessEntityID" integer NOT NULL,
    "AddressID" integer NOT NULL,
    "AddressTypeID" integer NOT NULL,
    "rowguid" uuid NOT NULL DEFAULT gen_random_uuid(),
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("BusinessEntityID", "AddressID", "AddressTypeID")
);
CREATE TABLE "Person"."BusinessEntityContact" (
    "BusinessEntityID" integer NOT NULL,
    "PersonID" integer NOT NULL,
    "ContactTypeID" integer NOT NULL,
    "rowguid" uuid NOT NULL DEFAULT gen_random_uuid(),
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("BusinessEntityID", "PersonID", "ContactTypeID")
);
CREATE TABLE "Person"."ContactType" (
    "ContactTypeID" integer,
    "Name" varchar(50) NOT NULL,
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("ContactTypeID")
);
CREATE TABLE "Sales"."CountryRegionCurrency" (
    "CountryRegionCode" varchar(3) NOT NULL,
    "CurrencyCode" char(3) NOT NULL,
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("CountryRegionCode", "CurrencyCode")
);
CREATE TABLE "Person"."CountryRegion" (
    "CountryRegionCode" varchar(3),
    "Name" varchar(50) NOT NULL,
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("CountryRegionCode")
);
CREATE TABLE "Sales"."CreditCard" (
    "CreditCardID" integer,
    "CardType" varchar(50) NOT NULL,
    "CardNumber" varchar(25) NOT NULL,
    "ExpMonth" smallint NOT NULL,
    "ExpYear" smallint NOT NULL,
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("CreditCardID")
);
CREATE TABLE "Production"."Culture" (
    "CultureID" char(6),
    "Name" varchar(50) NOT NULL,
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("CultureID")
);
CREATE TABLE "Sales"."Currency" (
    "CurrencyCode" char(3),
    "Name" varchar(50) NOT NULL,
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("CurrencyCode")
);
CREATE TABLE "Sales"."CurrencyRate" (
    "CurrencyRateID" integer,
    "CurrencyRateDate" timestamp NOT NULL,
    "FromCurrencyCode" char(3) NOT NULL,
    "ToCurrencyCode" char(3) NOT NULL,
    "AverageRate" numeric(19,4) NOT NULL,
    "EndOfDayRate" numeric(19,4) NOT NULL,
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("CurrencyRateID")
);
CREATE TABLE "Sales"."Customer" (
    "CustomerID" integer,
    "PersonID" integer,
    "StoreID" integer,
    "TerritoryID" integer,
    "AccountNumber" varchar(10),
    "rowguid" uuid NOT NULL DEFAULT gen_random_uuid(),
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("CustomerID")
);
CREATE TABLE "HumanResources"."Department" (
    "DepartmentID" smallint,
    "Name" varchar(50) NOT NULL,
    "GroupName" varchar(50) NOT NULL,
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("DepartmentID")
);
CREATE TABLE "Production"."Document" (
    "DocumentNode" text,
    "DocumentLevel" smallint,
    "Title" varchar(50) NOT NULL,
    "Owner" integer NOT NULL,
    "FolderFlag" boolean NOT NULL DEFAULT false,
    "FileName" varchar(400) NOT NULL,
    "FileExtension" varchar(8) NOT NULL,
    "Revision" char(5) NOT NULL,
    "ChangeNumber" integer NOT NULL DEFAULT 0,
    "Status" smallint NOT NULL,
    "DocumentSummary" text,
    "Document" bytea,
    "rowguid" uuid NOT NULL DEFAULT gen_random_uuid(),
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("DocumentNode")
);
CREATE TABLE "Person"."EmailAddress" (
    "BusinessEntityID" integer NOT NULL,
    "EmailAddressID" integer NOT NULL,
    "EmailAddress" varchar(50),
    "rowguid" uuid NOT NULL DEFAULT gen_random_uuid(),
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("BusinessEntityID", "EmailAddressID")
);
CREATE TABLE "HumanResources"."Employee" (
    "BusinessEntityID" integer,
    "NationalIDNumber" varchar(15) NOT NULL,
    "LoginID" varchar(256) NOT NULL,
    "OrganizationNode" text,
    "OrganizationLevel" smallint,
    "JobTitle" varchar(50) NOT NULL,
    "BirthDate" date NOT NULL,
    "MaritalStatus" char(1) NOT NULL,
    "Gender" char(1) NOT NULL,
    "HireDate" date NOT NULL,
    "SalariedFlag" boolean NOT NULL DEFAULT true,
    "VacationHours" smallint NOT NULL DEFAULT 0,
    "SickLeaveHours" smallint NOT NULL DEFAULT 0,
    "CurrentFlag" boolean NOT NULL DEFAULT true,
    "rowguid" uuid NOT NULL DEFAULT gen_random_uuid(),
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("BusinessEntityID")
);
CREATE TABLE "HumanResources"."EmployeeDepartmentHistory" (
    "BusinessEntityID" integer NOT NULL,
    "DepartmentID" smallint NOT NULL,
    "ShiftID" smallint NOT NULL,
    "StartDate" date NOT NULL,
    "EndDate" date,
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("BusinessEntityID", "StartDate", "DepartmentID", "ShiftID")
);
CREATE TABLE "HumanResources"."EmployeePayHistory" (
    "BusinessEntityID" integer NOT NULL,
    "RateChangeDate" timestamp NOT NULL,
    "Rate" numeric(19,4) NOT NULL,
    "PayFrequency" smallint NOT NULL,
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("BusinessEntityID", "RateChangeDate")
);
CREATE TABLE "Production"."Illustration" (
    "IllustrationID" integer,
    "Diagram" xml,
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("IllustrationID")
);
CREATE TABLE "HumanResources"."JobCandidate" (
    "JobCandidateID" integer,
    "BusinessEntityID" integer,
    "Resume" xml,
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("JobCandidateID")
);
CREATE TABLE "Production"."Location" (
    "LocationID" smallint,
    "Name" varchar(50) NOT NULL,
    "CostRate" numeric(10,4) NOT NULL DEFAULT 0.00,
    "Availability" numeric(8,2) NOT NULL DEFAULT 0.00,
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("LocationID")
);
CREATE TABLE "Person"."Password" (
    "BusinessEntityID" integer,
    "PasswordHash" varchar(128) NOT NULL,
    "PasswordSalt" varchar(10) NOT NULL,
    "rowguid" uuid NOT NULL DEFAULT gen_random_uuid(),
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("BusinessEntityID")
);
CREATE TABLE "Person"."Person" (
    "BusinessEntityID" integer,
    "PersonType" char(2) NOT NULL,
    "NameStyle" boolean NOT NULL DEFAULT false,
    "Title" varchar(8),
    "FirstName" varchar(50) NOT NULL,
    "MiddleName" varchar(50),
    "LastName" varchar(50) NOT NULL,
    "Suffix" varchar(10),
    "EmailPromotion" integer NOT NULL DEFAULT 0,
    "AdditionalContactInfo" xml,
    "Demographics" xml,
    "rowguid" uuid NOT NULL DEFAULT gen_random_uuid(),
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("BusinessEntityID")
);
CREATE TABLE "Sales"."PersonCreditCard" (
    "BusinessEntityID" integer NOT NULL,
    "CreditCardID" integer NOT NULL,
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("BusinessEntityID", "CreditCardID")
);
CREATE TABLE "Person"."PersonPhone" (
    "BusinessEntityID" integer NOT NULL,
    "PhoneNumber" varchar(25) NOT NULL,
    "PhoneNumberTypeID" integer NOT NULL,
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("BusinessEntityID", "PhoneNumber", "PhoneNumberTypeID")
);
CREATE TABLE "Person"."PhoneNumberType" (
    "PhoneNumberTypeID" integer,
    "Name" varchar(50) NOT NULL,
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("PhoneNumberTypeID")
);
CREATE TABLE "Production"."Product" (
    "ProductID" integer,
    "Name" varchar(50) NOT NULL,
    "ProductNumber" varchar(25) NOT NULL,
    "MakeFlag" boolean NOT NULL DEFAULT true,
    "FinishedGoodsFlag" boolean NOT NULL DEFAULT true,
    "Color" varchar(15),
    "SafetyStockLevel" smallint NOT NULL,
    "ReorderPoint" smallint NOT NULL,
    "StandardCost" numeric(19,4) NOT NULL,
    "ListPrice" numeric(19,4) NOT NULL,
    "Size" varchar(5),
    "SizeUnitMeasureCode" char(3),
    "WeightUnitMeasureCode" char(3),
    "Weight" numeric(8,2),
    "DaysToManufacture" integer NOT NULL,
    "ProductLine" char(2),
    "Class" char(2),
    "Style" char(2),
    "ProductSubcategoryID" integer,
    "ProductModelID" integer,
    "SellStartDate" timestamp NOT NULL,
    "SellEndDate" timestamp,
    "DiscontinuedDate" timestamp,
    "rowguid" uuid NOT NULL DEFAULT gen_random_uuid(),
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("ProductID")
);
CREATE TABLE "Production"."ProductCategory" (
    "ProductCategoryID" integer,
    "Name" varchar(50) NOT NULL,
    "rowguid" uuid NOT NULL DEFAULT gen_random_uuid(),
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("ProductCategoryID")
);
CREATE TABLE "Production"."ProductCostHistory" (
    "ProductID" integer NOT NULL,
    "StartDate" timestamp NOT NULL,
    "EndDate" timestamp,
    "StandardCost" numeric(19,4) NOT NULL,
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("ProductID", "StartDate")
);
CREATE TABLE "Production"."ProductDescription" (
    "ProductDescriptionID" integer,
    "Description" varchar(400) NOT NULL,
    "rowguid" uuid NOT NULL DEFAULT gen_random_uuid(),
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("ProductDescriptionID")
);
CREATE TABLE "Production"."ProductDocument" (
    "ProductID" integer NOT NULL,
    "DocumentNode" text NOT NULL,
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("ProductID", "DocumentNode")
);
CREATE TABLE "Production"."ProductInventory" (
    "ProductID" integer NOT NULL,
    "LocationID" smallint NOT NULL,
    "Shelf" varchar(10) NOT NULL,
    "Bin" smallint NOT NULL,
    "Quantity" smallint NOT NULL DEFAULT 0,
    "rowguid" uuid NOT NULL DEFAULT gen_random_uuid(),
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("ProductID", "LocationID")
);
CREATE TABLE "Production"."ProductListPriceHistory" (
    "ProductID" integer NOT NULL,
    "StartDate" timestamp NOT NULL,
    "EndDate" timestamp,
    "ListPrice" numeric(19,4) NOT NULL,
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("ProductID", "StartDate")
);
CREATE TABLE "Production"."ProductModel" (
    "ProductModelID" integer,
    "Name" varchar(50) NOT NULL,
    "CatalogDescription" xml,
    "Instructions" xml,
    "rowguid" uuid NOT NULL DEFAULT gen_random_uuid(),
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("ProductModelID")
);
CREATE TABLE "Production"."ProductModelIllustration" (
    "ProductModelID" integer NOT NULL,
    "IllustrationID" integer NOT NULL,
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("ProductModelID", "IllustrationID")
);
CREATE TABLE "Production"."ProductModelProductDescriptionCulture" (
    "ProductModelID" integer NOT NULL,
    "ProductDescriptionID" integer NOT NULL,
    "CultureID" char(6) NOT NULL,
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("ProductModelID", "ProductDescriptionID", "CultureID")
);
CREATE TABLE "Production"."ProductPhoto" (
    "ProductPhotoID" integer,
    "ThumbNailPhoto" bytea,
    "ThumbnailPhotoFileName" varchar(50),
    "LargePhoto" bytea,
    "LargePhotoFileName" varchar(50),
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("ProductPhotoID")
);
CREATE TABLE "Production"."ProductProductPhoto" (
    "ProductID" integer NOT NULL,
    "ProductPhotoID" integer NOT NULL,
    "Primary" boolean NOT NULL DEFAULT false,
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("ProductID", "ProductPhotoID")
);
CREATE TABLE "Production"."ProductReview" (
    "ProductReviewID" integer,
    "ProductID" integer NOT NULL,
    "ReviewerName" varchar(50) NOT NULL,
    "ReviewDate" timestamp NOT NULL DEFAULT now(),
    "EmailAddress" varchar(50) NOT NULL,
    "Rating" integer NOT NULL,
    "Comments" varchar(3850),
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("ProductReviewID")
);
CREATE TABLE "Production"."ProductSubcategory" (
    "ProductSubcategoryID" integer,
    "ProductCategoryID" integer NOT NULL,
    "Name" varchar(50) NOT NULL,
    "rowguid" uuid NOT NULL DEFAULT gen_random_uuid(),
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("ProductSubcategoryID")
);
CREATE TABLE "Purchasing"."ProductVendor" (
    "ProductID" integer NOT NULL,
    "BusinessEntityID" integer NOT NULL,
    "AverageLeadTime" integer NOT NULL,
    "StandardPrice" numeric(19,4) NOT NULL,
    "LastReceiptCost" numeric(19,4),
    "LastReceiptDate" timestamp,
    "MinOrderQty" integer NOT NULL,
    "MaxOrderQty" integer NOT NULL,
    "OnOrderQty" integer,
    "UnitMeasureCode" char(3) NOT NULL,
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("ProductID", "BusinessEntityID")
);
CREATE TABLE "Purchasing"."PurchaseOrderDetail" (
    "PurchaseOrderID" integer NOT NULL,
    "PurchaseOrderDetailID" integer NOT NULL,
    "DueDate" timestamp NOT NULL,
    "OrderQty" smallint NOT NULL,
    "ProductID" integer NOT NULL,
    "UnitPrice" numeric(19,4) NOT NULL,
    "LineTotal" numeric(19,4),
    "ReceivedQty" numeric(8,2) NOT NULL,
    "RejectedQty" numeric(8,2) NOT NULL,
    "StockedQty" numeric(9,2),
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("PurchaseOrderID", "PurchaseOrderDetailID")
);
CREATE TABLE "Purchasing"."PurchaseOrderHeader" (
    "PurchaseOrderID" integer,
    "RevisionNumber" smallint NOT NULL DEFAULT 0,
    "Status" smallint NOT NULL DEFAULT 1,
    "EmployeeID" integer NOT NULL,
    "VendorID" integer NOT NULL,
    "ShipMethodID" integer NOT NULL,
    "OrderDate" timestamp NOT NULL DEFAULT now(),
    "ShipDate" timestamp,
    "SubTotal" numeric(19,4) NOT NULL DEFAULT 0.00,
    "TaxAmt" numeric(19,4) NOT NULL DEFAULT 0.00,
    "Freight" numeric(19,4) NOT NULL DEFAULT 0.00,
    "TotalDue" numeric(19,4),
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("PurchaseOrderID")
);
CREATE TABLE "Sales"."SalesOrderDetail" (
    "SalesOrderID" integer NOT NULL,
    "SalesOrderDetailID" integer NOT NULL,
    "CarrierTrackingNumber" varchar(25),
    "OrderQty" smallint NOT NULL,
    "ProductID" integer NOT NULL,
    "SpecialOfferID" integer NOT NULL,
    "UnitPrice" numeric(19,4) NOT NULL,
    "UnitPriceDiscount" numeric(19,4) NOT NULL DEFAULT 0.0,
    "LineTotal" numeric(38,6),
    "rowguid" uuid NOT NULL DEFAULT gen_random_uuid(),
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("SalesOrderID", "SalesOrderDetailID")
);
CREATE TABLE "Sales"."SalesOrderHeader" (
    "SalesOrderID" integer,
    "RevisionNumber" smallint NOT NULL DEFAULT 0,
    "OrderDate" timestamp NOT NULL DEFAULT now(),
    "DueDate" timestamp NOT NULL,
    "ShipDate" timestamp,
    "Status" smallint NOT NULL DEFAULT 1,
    "OnlineOrderFlag" boolean NOT NULL DEFAULT true,
    "SalesOrderNumber" varchar(25),
    "PurchaseOrderNumber" varchar(25),
    "AccountNumber" varchar(15),
    "CustomerID" integer NOT NULL,
    "SalesPersonID" integer,
    "TerritoryID" integer,
    "BillToAddressID" integer NOT NULL,
    "ShipToAddressID" integer NOT NULL,
    "ShipMethodID" integer NOT NULL,
    "CreditCardID" integer,
    "CreditCardApprovalCode" varchar(15),
    "CurrencyRateID" integer,
    "SubTotal" numeric(19,4) NOT NULL DEFAULT 0.00,
    "TaxAmt" numeric(19,4) NOT NULL DEFAULT 0.00,
    "Freight" numeric(19,4) NOT NULL DEFAULT 0.00,
    "TotalDue" numeric(19,4),
    "Comment" varchar(128),
    "rowguid" uuid NOT NULL DEFAULT gen_random_uuid(),
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("SalesOrderID")
);
CREATE TABLE "Sales"."SalesOrderHeaderSalesReason" (
    "SalesOrderID" integer NOT NULL,
    "SalesReasonID" integer NOT NULL,
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("SalesOrderID", "SalesReasonID")
);
CREATE TABLE "Sales"."SalesPerson" (
    "BusinessEntityID" integer,
    "TerritoryID" integer,
    "SalesQuota" numeric(19,4),
    "Bonus" numeric(19,4) NOT NULL DEFAULT 0.00,
    "CommissionPct" numeric(10,4) NOT NULL DEFAULT 0.00,
    "SalesYTD" numeric(19,4) NOT NULL DEFAULT 0.00,
    "SalesLastYear" numeric(19,4) NOT NULL DEFAULT 0.00,
    "rowguid" uuid NOT NULL DEFAULT gen_random_uuid(),
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("BusinessEntityID")
);
CREATE TABLE "Sales"."SalesPersonQuotaHistory" (
    "BusinessEntityID" integer NOT NULL,
    "QuotaDate" timestamp NOT NULL,
    "SalesQuota" numeric(19,4) NOT NULL,
    "rowguid" uuid NOT NULL DEFAULT gen_random_uuid(),
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("BusinessEntityID", "QuotaDate")
);
CREATE TABLE "Sales"."SalesReason" (
    "SalesReasonID" integer,
    "Name" varchar(50) NOT NULL,
    "ReasonType" varchar(50) NOT NULL,
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("SalesReasonID")
);
CREATE TABLE "Sales"."SalesTaxRate" (
    "SalesTaxRateID" integer,
    "StateProvinceID" integer NOT NULL,
    "TaxType" smallint NOT NULL,
    "TaxRate" numeric(10,4) NOT NULL DEFAULT 0.00,
    "Name" varchar(50) NOT NULL,
    "rowguid" uuid NOT NULL DEFAULT gen_random_uuid(),
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("SalesTaxRateID")
);
CREATE TABLE "Sales"."SalesTerritory" (
    "TerritoryID" integer,
    "Name" varchar(50) NOT NULL,
    "CountryRegionCode" varchar(3) NOT NULL,
    "Group" varchar(50) NOT NULL,
    "SalesYTD" numeric(19,4) NOT NULL DEFAULT 0.00,
    "SalesLastYear" numeric(19,4) NOT NULL DEFAULT 0.00,
    "CostYTD" numeric(19,4) NOT NULL DEFAULT 0.00,
    "CostLastYear" numeric(19,4) NOT NULL DEFAULT 0.00,
    "rowguid" uuid NOT NULL DEFAULT gen_random_uuid(),
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("TerritoryID")
);
CREATE TABLE "Sales"."SalesTerritoryHistory" (
    "BusinessEntityID" integer NOT NULL,
    "TerritoryID" integer NOT NULL,
    "StartDate" timestamp NOT NULL,
    "EndDate" timestamp,
    "rowguid" uuid NOT NULL DEFAULT gen_random_uuid(),
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("BusinessEntityID", "StartDate", "TerritoryID")
);
CREATE TABLE "Production"."ScrapReason" (
    "ScrapReasonID" smallint,
    "Name" varchar(50) NOT NULL,
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("ScrapReasonID")
);
CREATE TABLE "HumanResources"."Shift" (
    "ShiftID" smallint,
    "Name" varchar(50) NOT NULL,
    "StartTime" time NOT NULL,
    "EndTime" time NOT NULL,
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("ShiftID")
);
CREATE TABLE "Purchasing"."ShipMethod" (
    "ShipMethodID" integer,
    "Name" varchar(50) NOT NULL,
    "ShipBase" numeric(19,4) NOT NULL DEFAULT 0.00,
    "ShipRate" numeric(19,4) NOT NULL DEFAULT 0.00,
    "rowguid" uuid NOT NULL DEFAULT gen_random_uuid(),
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("ShipMethodID")
);
CREATE TABLE "Sales"."ShoppingCartItem" (
    "ShoppingCartItemID" integer,
    "ShoppingCartID" varchar(50) NOT NULL,
    "Quantity" integer NOT NULL DEFAULT 1,
    "ProductID" integer NOT NULL,
    "DateCreated" timestamp NOT NULL DEFAULT now(),
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("ShoppingCartItemID")
);
CREATE TABLE "Sales"."SpecialOffer" (
    "SpecialOfferID" integer,
    "Description" varchar(255) NOT NULL,
    "DiscountPct" numeric(10,4) NOT NULL DEFAULT 0.00,
    "Type" varchar(50) NOT NULL,
    "Category" varchar(50) NOT NULL,
    "StartDate" timestamp NOT NULL,
    "EndDate" timestamp NOT NULL,
    "MinQty" integer NOT NULL DEFAULT 0,
    "MaxQty" integer,
    "rowguid" uuid NOT NULL DEFAULT gen_random_uuid(),
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("SpecialOfferID")
);
CREATE TABLE "Sales"."SpecialOfferProduct" (
    "SpecialOfferID" integer NOT NULL,
    "ProductID" integer NOT NULL,
    "rowguid" uuid NOT NULL DEFAULT gen_random_uuid(),
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("SpecialOfferID", "ProductID")
);
CREATE TABLE "Person"."StateProvince" (
    "StateProvinceID" integer,
    "StateProvinceCode" char(3) NOT NULL,
    "CountryRegionCode" varchar(3) NOT NULL,
    "IsOnlyStateProvinceFlag" boolean NOT NULL DEFAULT true,
    "Name" varchar(50) NOT NULL,
    "TerritoryID" integer NOT NULL,
    "rowguid" uuid NOT NULL DEFAULT gen_random_uuid(),
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("StateProvinceID")
);
CREATE TABLE "Sales"."Store" (
    "BusinessEntityID" integer,
    "Name" varchar(50) NOT NULL,
    "SalesPersonID" integer,
    "Demographics" xml,
    "rowguid" uuid NOT NULL DEFAULT gen_random_uuid(),
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("BusinessEntityID")
);
CREATE TABLE "Production"."TransactionHistory" (
    "TransactionID" integer,
    "ProductID" integer NOT NULL,
    "ReferenceOrderID" integer NOT NULL,
    "ReferenceOrderLineID" integer NOT NULL DEFAULT 0,
    "TransactionDate" timestamp NOT NULL DEFAULT now(),
    "TransactionType" char(1) NOT NULL,
    "Quantity" integer NOT NULL,
    "ActualCost" numeric(19,4) NOT NULL,
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("TransactionID")
);
CREATE TABLE "Production"."TransactionHistoryArchive" (
    "TransactionID" integer,
    "ProductID" integer NOT NULL,
    "ReferenceOrderID" integer NOT NULL,
    "ReferenceOrderLineID" integer NOT NULL DEFAULT 0,
    "TransactionDate" timestamp NOT NULL DEFAULT now(),
    "TransactionType" char(1) NOT NULL,
    "Quantity" integer NOT NULL,
    "ActualCost" numeric(19,4) NOT NULL,
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("TransactionID")
);
CREATE TABLE "Production"."UnitMeasure" (
    "UnitMeasureCode" char(3),
    "Name" varchar(50) NOT NULL,
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("UnitMeasureCode")
);
CREATE TABLE "Purchasing"."Vendor" (
    "BusinessEntityID" integer,
    "AccountNumber" varchar(15) NOT NULL,
    "Name" varchar(50) NOT NULL,
    "CreditRating" smallint NOT NULL,
    "PreferredVendorStatus" boolean NOT NULL DEFAULT true,
    "ActiveFlag" boolean NOT NULL DEFAULT true,
    "PurchasingWebServiceURL" varchar(1024),
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("BusinessEntityID")
);
CREATE TABLE "Production"."WorkOrder" (
    "WorkOrderID" integer,
    "ProductID" integer NOT NULL,
    "OrderQty" integer NOT NULL,
    "StockedQty" integer,
    "ScrappedQty" smallint NOT NULL,
    "StartDate" timestamp NOT NULL,
    "EndDate" timestamp,
    "DueDate" timestamp NOT NULL,
    "ScrapReasonID" smallint,
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("WorkOrderID")
);
CREATE TABLE "Production"."WorkOrderRouting" (
    "WorkOrderID" integer NOT NULL,
    "ProductID" integer NOT NULL,
    "OperationSequence" smallint NOT NULL,
    "LocationID" smallint NOT NULL,
    "ScheduledStartDate" timestamp NOT NULL,
    "ScheduledEndDate" timestamp NOT NULL,
    "ActualStartDate" timestamp,
    "ActualEndDate" timestamp,
    "ActualResourceHrs" numeric(9,4),
    "PlannedCost" numeric(19,4) NOT NULL,
    "ActualCost" numeric(19,4),
    "ModifiedDate" timestamp NOT NULL DEFAULT now(),
    PRIMARY KEY ("WorkOrderID", "ProductID", "OperationSequence")
);

ALTER TABLE "Person"."Address" ADD FOREIGN KEY ("StateProvinceID") REFERENCES "Person"."StateProvince" ("StateProvinceID");
ALTER TABLE "Production"."BillOfMaterials" ADD FOREIGN KEY ("ProductAssemblyID") REFERENCES "Production"."Product" ("ProductID");
ALTER TABLE "Production"."BillOfMaterials" ADD FOREIGN KEY ("ComponentID") REFERENCES "Production"."Product" ("ProductID");
ALTER TABLE "Production"."BillOfMaterials" ADD FOREIGN KEY ("UnitMeasureCode") REFERENCES "Production"."UnitMeasure" ("UnitMeasureCode");
ALTER TABLE "Person"."BusinessEntityAddress" ADD FOREIGN KEY ("AddressID") REFERENCES "Person"."Address" ("AddressID");
ALTER TABLE "Person"."BusinessEntityAddress" ADD FOREIGN KEY ("AddressTypeID") REFERENCES "Person"."AddressType" ("AddressTypeID");
ALTER TABLE "Person"."BusinessEntityAddress" ADD FOREIGN KEY ("BusinessEntityID") REFERENCES "Person"."BusinessEntity" ("BusinessEntityID");
ALTER TABLE "Person"."BusinessEntityContact" ADD FOREIGN KEY ("PersonID") REFERENCES "Person"."Person" ("BusinessEntityID");
ALTER TABLE "Person"."BusinessEntityContact" ADD FOREIGN KEY ("ContactTypeID") REFERENCES "Person"."ContactType" ("ContactTypeID");
ALTER TABLE "Person"."BusinessEntityContact" ADD FOREIGN KEY ("BusinessEntityID") REFERENCES "Person"."BusinessEntity" ("BusinessEntityID");
ALTER TABLE "Sales"."CountryRegionCurrency" ADD FOREIGN KEY ("CountryRegionCode") REFERENCES "Person"."CountryRegion" ("CountryRegionCode");
ALTER TABLE "Sales"."CountryRegionCurrency" ADD FOREIGN KEY ("CurrencyCode") REFERENCES "Sales"."Currency" ("CurrencyCode");
ALTER TABLE "Sales"."CurrencyRate" ADD FOREIGN KEY ("FromCurrencyCode") REFERENCES "Sales"."Currency" ("CurrencyCode");
ALTER TABLE "Sales"."CurrencyRate" ADD FOREIGN KEY ("ToCurrencyCode") REFERENCES "Sales"."Currency" ("CurrencyCode");
ALTER TABLE "Sales"."Customer" ADD FOREIGN KEY ("PersonID") REFERENCES "Person"."Person" ("BusinessEntityID");
ALTER TABLE "Sales"."Customer" ADD FOREIGN KEY ("StoreID") REFERENCES "Sales"."Store" ("BusinessEntityID");
ALTER TABLE "Sales"."Customer" ADD FOREIGN KEY ("TerritoryID") REFERENCES "Sales"."SalesTerritory" ("TerritoryID");
ALTER TABLE "Production"."Document" ADD FOREIGN KEY ("Owner") REFERENCES "HumanResources"."Employee" ("BusinessEntityID");
ALTER TABLE "Person"."EmailAddress" ADD FOREIGN KEY ("BusinessEntityID") REFERENCES "Person"."Person" ("BusinessEntityID");
ALTER TABLE "HumanResources"."Employee" ADD FOREIGN KEY ("BusinessEntityID") REFERENCES "Person"."Person" ("BusinessEntityID");
ALTER TABLE "HumanResources"."EmployeeDepartmentHistory" ADD FOREIGN KEY ("DepartmentID") REFERENCES "HumanResources"."Department" ("DepartmentID");
ALTER TABLE "HumanResources"."EmployeeDepartmentHistory" ADD FOREIGN KEY ("BusinessEntityID") REFERENCES "HumanResources"."Employee" ("BusinessEntityID");
ALTER TABLE "HumanResources"."EmployeeDepartmentHistory" ADD FOREIGN KEY ("ShiftID") REFERENCES "HumanResources"."Shift" ("ShiftID");
ALTER TABLE "HumanResources"."EmployeePayHistory" ADD FOREIGN KEY ("BusinessEntityID") REFERENCES "HumanResources"."Employee" ("BusinessEntityID");
ALTER TABLE "HumanResources"."JobCandidate" ADD FOREIGN KEY ("BusinessEntityID") REFERENCES "HumanResources"."Employee" ("BusinessEntityID");
ALTER TABLE "Person"."Password" ADD FOREIGN KEY ("BusinessEntityID") REFERENCES "Person"."Person" ("BusinessEntityID");
ALTER TABLE "Person"."Person" ADD FOREIGN KEY ("BusinessEntityID") REFERENCES "Person"."BusinessEntity" ("BusinessEntityID");
ALTER TABLE "Sales"."PersonCreditCard" ADD FOREIGN KEY ("BusinessEntityID") REFERENCES "Person"."Person" ("BusinessEntityID");
ALTER TABLE "Sales"."PersonCreditCard" ADD FOREIGN KEY ("CreditCardID") REFERENCES "Sales"."CreditCard" ("CreditCardID");
ALTER TABLE "Person"."PersonPhone" ADD FOREIGN KEY ("BusinessEntityID") REFERENCES "Person"."Person" ("BusinessEntityID");
ALTER TABLE "Person"."PersonPhone" ADD FOREIGN KEY ("PhoneNumberTypeID") REFERENCES "Person"."PhoneNumberType" ("PhoneNumberTypeID");
ALTER TABLE "Production"."Product" ADD FOREIGN KEY ("SizeUnitMeasureCode") REFERENCES "Production"."UnitMeasure" ("UnitMeasureCode");
ALTER TABLE "Production"."Product" ADD FOREIGN KEY ("WeightUnitMeasureCode") REFERENCES "Production"."UnitMeasure" ("UnitMeasureCode");
ALTER TABLE "Production"."Product" ADD FOREIGN KEY ("ProductModelID") REFERENCES "Production"."ProductModel" ("ProductModelID");
ALTER TABLE "Production"."Product" ADD FOREIGN KEY ("ProductSubcategoryID") REFERENCES "Production"."ProductSubcategory" ("ProductSubcategoryID");
ALTER TABLE "Production"."ProductCostHistory" ADD FOREIGN KEY ("ProductID") REFERENCES "Production"."Product" ("ProductID");
ALTER TABLE "Production"."ProductDocument" ADD FOREIGN KEY ("ProductID") REFERENCES "Production"."Product" ("ProductID");
ALTER TABLE "Production"."ProductDocument" ADD FOREIGN KEY ("DocumentNode") REFERENCES "Production"."Document" ("DocumentNode");
ALTER TABLE "Production"."ProductInventory" ADD FOREIGN KEY ("LocationID") REFERENCES "Production"."Location" ("LocationID");
ALTER TABLE "Production"."ProductInventory" ADD FOREIGN KEY ("ProductID") REFERENCES "Production"."Product" ("ProductID");
ALTER TABLE "Production"."ProductListPriceHistory" ADD FOREIGN KEY ("ProductID") REFERENCES "Production"."Product" ("ProductID");
ALTER TABLE "Production"."ProductModelIllustration" ADD FOREIGN KEY ("ProductModelID") REFERENCES "Production"."ProductModel" ("ProductModelID");
ALTER TABLE "Production"."ProductModelIllustration" ADD FOREIGN KEY ("IllustrationID") REFERENCES "Production"."Illustration" ("IllustrationID");
ALTER TABLE "Production"."ProductModelProductDescriptionCulture" ADD FOREIGN KEY ("ProductDescriptionID") REFERENCES "Production"."ProductDescription" ("ProductDescriptionID");
ALTER TABLE "Production"."ProductModelProductDescriptionCulture" ADD FOREIGN KEY ("CultureID") REFERENCES "Production"."Culture" ("CultureID");
ALTER TABLE "Production"."ProductModelProductDescriptionCulture" ADD FOREIGN KEY ("ProductModelID") REFERENCES "Production"."ProductModel" ("ProductModelID");
ALTER TABLE "Production"."ProductProductPhoto" ADD FOREIGN KEY ("ProductID") REFERENCES "Production"."Product" ("ProductID");
ALTER TABLE "Production"."ProductProductPhoto" ADD FOREIGN KEY ("ProductPhotoID") REFERENCES "Production"."ProductPhoto" ("ProductPhotoID");
ALTER TABLE "Production"."ProductReview" ADD FOREIGN KEY ("ProductID") REFERENCES "Production"."Product" ("ProductID");
ALTER TABLE "Production"."ProductSubcategory" ADD FOREIGN KEY ("ProductCategoryID") REFERENCES "Production"."ProductCategory" ("ProductCategoryID");
ALTER TABLE "Purchasing"."ProductVendor" ADD FOREIGN KEY ("ProductID") REFERENCES "Production"."Product" ("ProductID");
ALTER TABLE "Purchasing"."ProductVendor" ADD FOREIGN KEY ("UnitMeasureCode") REFERENCES "Production"."UnitMeasure" ("UnitMeasureCode");
ALTER TABLE "Purchasing"."ProductVendor" ADD FOREIGN KEY ("BusinessEntityID") REFERENCES "Purchasing"."Vendor" ("BusinessEntityID");
ALTER TABLE "Purchasing"."PurchaseOrderDetail" ADD FOREIGN KEY ("ProductID") REFERENCES "Production"."Product" ("ProductID");
ALTER TABLE "Purchasing"."PurchaseOrderDetail" ADD FOREIGN KEY ("PurchaseOrderID") REFERENCES "Purchasing"."PurchaseOrderHeader" ("PurchaseOrderID");
ALTER TABLE "Purchasing"."PurchaseOrderHeader" ADD FOREIGN KEY ("EmployeeID") REFERENCES "HumanResources"."Employee" ("BusinessEntityID");
ALTER TABLE "Purchasing"."PurchaseOrderHeader" ADD FOREIGN KEY ("VendorID") REFERENCES "Purchasing"."Vendor" ("BusinessEntityID");
ALTER TABLE "Purchasing"."PurchaseOrderHeader" ADD FOREIGN KEY ("ShipMethodID") REFERENCES "Purchasing"."ShipMethod" ("ShipMethodID");
ALTER TABLE "Sales"."SalesOrderDetail" ADD FOREIGN KEY ("SalesOrderID") REFERENCES "Sales"."SalesOrderHeader" ("SalesOrderID");
ALTER TABLE "Sales"."SalesOrderDetail" ADD FOREIGN KEY ("SpecialOfferID", "ProductID") REFERENCES "Sales"."SpecialOfferProduct" ("SpecialOfferID", "ProductID");
ALTER TABLE "Sales"."SalesOrderHeader" ADD FOREIGN KEY ("BillToAddressID") REFERENCES "Person"."Address" ("AddressID");
ALTER TABLE "Sales"."SalesOrderHeader" ADD FOREIGN KEY ("ShipToAddressID") REFERENCES "Person"."Address" ("AddressID");
ALTER TABLE "Sales"."SalesOrderHeader" ADD FOREIGN KEY ("CreditCardID") REFERENCES "Sales"."CreditCard" ("CreditCardID");
ALTER TABLE "Sales"."SalesOrderHeader" ADD FOREIGN KEY ("CurrencyRateID") REFERENCES "Sales"."CurrencyRate" ("CurrencyRateID");
ALTER TABLE "Sales"."SalesOrderHeader" ADD FOREIGN KEY ("CustomerID") REFERENCES "Sales"."Customer" ("CustomerID");
ALTER TABLE "Sales"."SalesOrderHeader" ADD FOREIGN KEY ("SalesPersonID") REFERENCES "Sales"."SalesPerson" ("BusinessEntityID");
ALTER TABLE "Sales"."SalesOrderHeader" ADD FOREIGN KEY ("ShipMethodID") REFERENCES "Purchasing"."ShipMethod" ("ShipMethodID");
ALTER TABLE "Sales"."SalesOrderHeader" ADD FOREIGN KEY ("TerritoryID") REFERENCES "Sales"."SalesTerritory" ("TerritoryID");
ALTER TABLE "Sales"."SalesOrderHeaderSalesReason" ADD FOREIGN KEY ("SalesReasonID") REFERENCES "Sales"."SalesReason" ("SalesReasonID");
ALTER TABLE "Sales"."SalesOrderHeaderSalesReason" ADD FOREIGN KEY ("SalesOrderID") REFERENCES "Sales"."SalesOrderHeader" ("SalesOrderID");
ALTER TABLE "Sales"."SalesPerson" ADD FOREIGN KEY ("BusinessEntityID") REFERENCES "HumanResources"."Employee" ("BusinessEntityID");
ALTER TABLE "Sales"."SalesPerson" ADD FOREIGN KEY ("TerritoryID") REFERENCES "Sales"."SalesTerritory" ("TerritoryID");
ALTER TABLE "Sales"."SalesPersonQuotaHistory" ADD FOREIGN KEY ("BusinessEntityID") REFERENCES "Sales"."SalesPerson" ("BusinessEntityID");
ALTER TABLE "Sales"."SalesTaxRate" ADD FOREIGN KEY ("StateProvinceID") REFERENCES "Person"."StateProvince" ("StateProvinceID");
ALTER TABLE "Sales"."SalesTerritory" ADD FOREIGN KEY ("CountryRegionCode") REFERENCES "Person"."CountryRegion" ("CountryRegionCode");
ALTER TABLE "Sales"."SalesTerritoryHistory" ADD FOREIGN KEY ("BusinessEntityID") REFERENCES "Sales"."SalesPerson" ("BusinessEntityID");
ALTER TABLE "Sales"."SalesTerritoryHistory" ADD FOREIGN KEY ("TerritoryID") REFERENCES "Sales"."SalesTerritory" ("TerritoryID");
ALTER TABLE "Sales"."ShoppingCartItem" ADD FOREIGN KEY ("ProductID") REFERENCES "Production"."Product" ("ProductID");
ALTER TABLE "Sales"."SpecialOfferProduct" ADD FOREIGN KEY ("ProductID") REFERENCES "Production"."Product" ("ProductID");
ALTER TABLE "Sales"."SpecialOfferProduct" ADD FOREIGN KEY ("SpecialOfferID") REFERENCES "Sales"."SpecialOffer" ("SpecialOfferID");
ALTER TABLE "Person"."StateProvince" ADD FOREIGN KEY ("CountryRegionCode") REFERENCES "Person"."CountryRegion" ("CountryRegionCode");
ALTER TABLE "Person"."StateProvince" ADD FOREIGN KEY ("TerritoryID") REFERENCES "Sales"."SalesTerritory" ("TerritoryID");
ALTER TABLE "Sales"."Store" ADD FOREIGN KEY ("BusinessEntityID") REFERENCES "Person"."BusinessEntity" ("BusinessEntityID");
ALTER TABLE "Sales"."Store" ADD FOREIGN KEY ("SalesPersonID") REFERENCES "Sales"."SalesPerson" ("BusinessEntityID");
ALTER TABLE "Production"."TransactionHistory" ADD FOREIGN KEY ("ProductID") REFERENCES "Production"."Product" ("ProductID");
ALTER TABLE "Purchasing"."Vendor" ADD FOREIGN KEY ("BusinessEntityID") REFERENCES "Person"."BusinessEntity" ("BusinessEntityID");
ALTER TABLE "Production"."WorkOrder" ADD FOREIGN KEY ("ProductID") REFERENCES "Production"."Product" ("ProductID");
ALTER TABLE "Production"."WorkOrder" ADD FOREIGN KEY ("ScrapReasonID") REFERENCES "Production"."ScrapReason" ("ScrapReasonID");
ALTER TABLE "Production"."WorkOrderRouting" ADD FOREIGN KEY ("LocationID") REFERENCES "Production"."Location" ("LocationID");
ALTER TABLE "Production"."WorkOrderRouting" ADD FOREIGN KEY ("WorkOrderID") REFERENCES "Production"."WorkOrder" ("WorkOrderID");

COMMENT ON COLUMN "Person"."Address"."AddressID" IS 'Primary key for Address records.';
COMMENT ON COLUMN "Person"."Address"."AddressLine1" IS 'First street address line.';
COMMENT ON COLUMN "Person"."Address"."AddressLine2" IS 'Second street address line.';
COMMENT ON COLUMN "Person"."Address"."City" IS 'Name of the city.';
COMMENT ON COLUMN "Person"."Address"."StateProvinceID" IS 'Unique identification number for the state or province. Foreign key to StateProvince table.';
COMMENT ON COLUMN "Person"."Address"."PostalCode" IS 'Postal code for the street address.';
COMMENT ON COLUMN "Person"."Address"."SpatialLocation" IS 'Latitude and longitude of this address. — SQL Server geography: a point on the globe';
COMMENT ON COLUMN "Person"."Address"."rowguid" IS 'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
COMMENT ON COLUMN "Person"."Address"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Person"."Address" IS 'Street address information for customers, employees, and vendors.';
COMMENT ON COLUMN "Person"."AddressType"."AddressTypeID" IS 'Primary key for AddressType records.';
COMMENT ON COLUMN "Person"."AddressType"."Name" IS 'Address type description. For example, Billing, Home, or Shipping. — SQL Server alias type Name';
COMMENT ON COLUMN "Person"."AddressType"."rowguid" IS 'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
COMMENT ON COLUMN "Person"."AddressType"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Person"."AddressType" IS 'Types of addresses stored in the Address table.';
COMMENT ON COLUMN "Production"."BillOfMaterials"."BillOfMaterialsID" IS 'Primary key for BillOfMaterials records.';
COMMENT ON COLUMN "Production"."BillOfMaterials"."ProductAssemblyID" IS 'Parent product identification number. Foreign key to Product.ProductID.';
COMMENT ON COLUMN "Production"."BillOfMaterials"."ComponentID" IS 'Component identification number. Foreign key to Product.ProductID.';
COMMENT ON COLUMN "Production"."BillOfMaterials"."StartDate" IS 'Date the component started being used in the assembly item.';
COMMENT ON COLUMN "Production"."BillOfMaterials"."EndDate" IS 'Date the component stopped being used in the assembly item.';
COMMENT ON COLUMN "Production"."BillOfMaterials"."UnitMeasureCode" IS 'Standard code identifying the unit of measure for the quantity.';
COMMENT ON COLUMN "Production"."BillOfMaterials"."BOMLevel" IS 'Indicates the depth the component is from its parent (AssemblyID).';
COMMENT ON COLUMN "Production"."BillOfMaterials"."PerAssemblyQty" IS 'Quantity of the component needed to create the assembly.';
COMMENT ON COLUMN "Production"."BillOfMaterials"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Production"."BillOfMaterials" IS 'Items required to make bicycles and bicycle subassemblies. It identifies the heirarchical relationship between a parent product and its components.';
COMMENT ON COLUMN "Person"."BusinessEntity"."BusinessEntityID" IS 'Primary key for all customers, vendors, and employees.';
COMMENT ON COLUMN "Person"."BusinessEntity"."rowguid" IS 'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
COMMENT ON COLUMN "Person"."BusinessEntity"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Person"."BusinessEntity" IS 'Source of the ID that connects vendors, customers, and employees with address and contact information.';
COMMENT ON COLUMN "Person"."BusinessEntityAddress"."BusinessEntityID" IS 'Primary key. Foreign key to BusinessEntity.BusinessEntityID.';
COMMENT ON COLUMN "Person"."BusinessEntityAddress"."AddressID" IS 'Primary key. Foreign key to Address.AddressID.';
COMMENT ON COLUMN "Person"."BusinessEntityAddress"."AddressTypeID" IS 'Primary key. Foreign key to AddressType.AddressTypeID.';
COMMENT ON COLUMN "Person"."BusinessEntityAddress"."rowguid" IS 'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
COMMENT ON COLUMN "Person"."BusinessEntityAddress"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Person"."BusinessEntityAddress" IS 'Cross-reference table mapping customers, vendors, and employees to their addresses.';
COMMENT ON COLUMN "Person"."BusinessEntityContact"."BusinessEntityID" IS 'Primary key. Foreign key to BusinessEntity.BusinessEntityID.';
COMMENT ON COLUMN "Person"."BusinessEntityContact"."PersonID" IS 'Primary key. Foreign key to Person.BusinessEntityID.';
COMMENT ON COLUMN "Person"."BusinessEntityContact"."ContactTypeID" IS 'Primary key.  Foreign key to ContactType.ContactTypeID.';
COMMENT ON COLUMN "Person"."BusinessEntityContact"."rowguid" IS 'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
COMMENT ON COLUMN "Person"."BusinessEntityContact"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Person"."BusinessEntityContact" IS 'Cross-reference table mapping stores, vendors, and employees to people';
COMMENT ON COLUMN "Person"."ContactType"."ContactTypeID" IS 'Primary key for ContactType records.';
COMMENT ON COLUMN "Person"."ContactType"."Name" IS 'Contact type description. — SQL Server alias type Name';
COMMENT ON COLUMN "Person"."ContactType"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Person"."ContactType" IS 'Lookup table containing the types of business entity contacts.';
COMMENT ON COLUMN "Sales"."CountryRegionCurrency"."CountryRegionCode" IS 'ISO code for countries and regions. Foreign key to CountryRegion.CountryRegionCode.';
COMMENT ON COLUMN "Sales"."CountryRegionCurrency"."CurrencyCode" IS 'ISO standard currency code. Foreign key to Currency.CurrencyCode.';
COMMENT ON COLUMN "Sales"."CountryRegionCurrency"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Sales"."CountryRegionCurrency" IS 'Cross-reference table mapping ISO currency codes to a country or region.';
COMMENT ON COLUMN "Person"."CountryRegion"."CountryRegionCode" IS 'ISO standard code for countries and regions.';
COMMENT ON COLUMN "Person"."CountryRegion"."Name" IS 'Country or region name. — SQL Server alias type Name';
COMMENT ON COLUMN "Person"."CountryRegion"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Person"."CountryRegion" IS 'Lookup table containing the ISO standard codes for countries and regions.';
COMMENT ON COLUMN "Sales"."CreditCard"."CreditCardID" IS 'Primary key for CreditCard records.';
COMMENT ON COLUMN "Sales"."CreditCard"."CardType" IS 'Credit card name.';
COMMENT ON COLUMN "Sales"."CreditCard"."CardNumber" IS 'Credit card number.';
COMMENT ON COLUMN "Sales"."CreditCard"."ExpMonth" IS 'Credit card expiration month.';
COMMENT ON COLUMN "Sales"."CreditCard"."ExpYear" IS 'Credit card expiration year.';
COMMENT ON COLUMN "Sales"."CreditCard"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Sales"."CreditCard" IS 'Customer credit card information.';
COMMENT ON COLUMN "Production"."Culture"."CultureID" IS 'Primary key for Culture records.';
COMMENT ON COLUMN "Production"."Culture"."Name" IS 'Culture description. — SQL Server alias type Name';
COMMENT ON COLUMN "Production"."Culture"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Production"."Culture" IS 'Lookup table containing the languages in which some AdventureWorks data is stored.';
COMMENT ON COLUMN "Sales"."Currency"."CurrencyCode" IS 'The ISO code for the Currency.';
COMMENT ON COLUMN "Sales"."Currency"."Name" IS 'Currency name. — SQL Server alias type Name';
COMMENT ON COLUMN "Sales"."Currency"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Sales"."Currency" IS 'Lookup table containing standard ISO currencies.';
COMMENT ON COLUMN "Sales"."CurrencyRate"."CurrencyRateID" IS 'Primary key for CurrencyRate records.';
COMMENT ON COLUMN "Sales"."CurrencyRate"."CurrencyRateDate" IS 'Date and time the exchange rate was obtained.';
COMMENT ON COLUMN "Sales"."CurrencyRate"."FromCurrencyCode" IS 'Exchange rate was converted from this currency code.';
COMMENT ON COLUMN "Sales"."CurrencyRate"."ToCurrencyCode" IS 'Exchange rate was converted to this currency code.';
COMMENT ON COLUMN "Sales"."CurrencyRate"."AverageRate" IS 'Average exchange rate for the day.';
COMMENT ON COLUMN "Sales"."CurrencyRate"."EndOfDayRate" IS 'Final exchange rate for the day.';
COMMENT ON COLUMN "Sales"."CurrencyRate"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Sales"."CurrencyRate" IS 'Currency exchange rates.';
COMMENT ON COLUMN "Sales"."Customer"."CustomerID" IS 'Primary key.';
COMMENT ON COLUMN "Sales"."Customer"."PersonID" IS 'Foreign key to Person.BusinessEntityID';
COMMENT ON COLUMN "Sales"."Customer"."StoreID" IS 'Foreign key to Store.BusinessEntityID';
COMMENT ON COLUMN "Sales"."Customer"."TerritoryID" IS 'ID of the territory in which the customer is located. Foreign key to SalesTerritory.SalesTerritoryID.';
COMMENT ON COLUMN "Sales"."Customer"."AccountNumber" IS 'Unique number identifying the customer assigned by the accounting system. — Computed in SQL Server: ''AW'' + the CustomerID zero-padded';
COMMENT ON COLUMN "Sales"."Customer"."rowguid" IS 'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
COMMENT ON COLUMN "Sales"."Customer"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Sales"."Customer" IS 'Current customer information. Also see the Person and Store tables.';
COMMENT ON COLUMN "HumanResources"."Department"."DepartmentID" IS 'Primary key for Department records.';
COMMENT ON COLUMN "HumanResources"."Department"."Name" IS 'Name of the department. — SQL Server alias type Name';
COMMENT ON COLUMN "HumanResources"."Department"."GroupName" IS 'Name of the group to which the department belongs. — SQL Server alias type Name';
COMMENT ON COLUMN "HumanResources"."Department"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "HumanResources"."Department" IS 'Lookup table containing the departments within the Adventure Works Cycles company.';
COMMENT ON COLUMN "Production"."Document"."DocumentNode" IS 'Primary key for Document records. — SQL Server hierarchyid: a position in a tree, e.g. /1/3/';
COMMENT ON COLUMN "Production"."Document"."DocumentLevel" IS 'Depth in the document hierarchy. — Computed in SQL Server: DocumentNode.GetLevel()';
COMMENT ON COLUMN "Production"."Document"."Title" IS 'Title of the document.';
COMMENT ON COLUMN "Production"."Document"."Owner" IS 'Employee who controls the document.  Foreign key to Employee.BusinessEntityID';
COMMENT ON COLUMN "Production"."Document"."FolderFlag" IS '0 = This is a folder, 1 = This is a document.';
COMMENT ON COLUMN "Production"."Document"."FileName" IS 'File name of the document';
COMMENT ON COLUMN "Production"."Document"."FileExtension" IS 'File extension indicating the document type. For example, .doc or .txt.';
COMMENT ON COLUMN "Production"."Document"."Revision" IS 'Revision number of the document. ';
COMMENT ON COLUMN "Production"."Document"."ChangeNumber" IS 'Engineering change approval number.';
COMMENT ON COLUMN "Production"."Document"."Status" IS '1 = Pending approval, 2 = Approved, 3 = Obsolete';
COMMENT ON COLUMN "Production"."Document"."DocumentSummary" IS 'Document abstract.';
COMMENT ON COLUMN "Production"."Document"."Document" IS 'Complete document.';
COMMENT ON COLUMN "Production"."Document"."rowguid" IS 'ROWGUIDCOL number uniquely identifying the record. Required for FileStream.';
COMMENT ON COLUMN "Production"."Document"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Production"."Document" IS 'Product maintenance documents.';
COMMENT ON COLUMN "Person"."EmailAddress"."BusinessEntityID" IS 'Primary key. Person associated with this email address.  Foreign key to Person.BusinessEntityID';
COMMENT ON COLUMN "Person"."EmailAddress"."EmailAddressID" IS 'Primary key. ID of this email address.';
COMMENT ON COLUMN "Person"."EmailAddress"."EmailAddress" IS 'E-mail address for the person.';
COMMENT ON COLUMN "Person"."EmailAddress"."rowguid" IS 'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
COMMENT ON COLUMN "Person"."EmailAddress"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Person"."EmailAddress" IS 'Where to send a person email.';
COMMENT ON COLUMN "HumanResources"."Employee"."BusinessEntityID" IS 'Primary key for Employee records.  Foreign key to BusinessEntity.BusinessEntityID.';
COMMENT ON COLUMN "HumanResources"."Employee"."NationalIDNumber" IS 'Unique national identification number such as a social security number.';
COMMENT ON COLUMN "HumanResources"."Employee"."LoginID" IS 'Network login.';
COMMENT ON COLUMN "HumanResources"."Employee"."OrganizationNode" IS 'Where the employee is located in corporate hierarchy. — SQL Server hierarchyid: a position in a tree, e.g. /1/3/';
COMMENT ON COLUMN "HumanResources"."Employee"."OrganizationLevel" IS 'The depth of the employee in the corporate hierarchy. — Computed in SQL Server: OrganizationNode.GetLevel()';
COMMENT ON COLUMN "HumanResources"."Employee"."JobTitle" IS 'Work title such as Buyer or Sales Representative.';
COMMENT ON COLUMN "HumanResources"."Employee"."BirthDate" IS 'Date of birth.';
COMMENT ON COLUMN "HumanResources"."Employee"."MaritalStatus" IS 'M = Married, S = Single';
COMMENT ON COLUMN "HumanResources"."Employee"."Gender" IS 'M = Male, F = Female';
COMMENT ON COLUMN "HumanResources"."Employee"."HireDate" IS 'Employee hired on this date.';
COMMENT ON COLUMN "HumanResources"."Employee"."SalariedFlag" IS 'Job classification. 0 = Hourly, not exempt from collective bargaining. 1 = Salaried, exempt from collective bargaining. — SQL Server alias type Flag';
COMMENT ON COLUMN "HumanResources"."Employee"."VacationHours" IS 'Number of available vacation hours.';
COMMENT ON COLUMN "HumanResources"."Employee"."SickLeaveHours" IS 'Number of available sick leave hours.';
COMMENT ON COLUMN "HumanResources"."Employee"."CurrentFlag" IS '0 = Inactive, 1 = Active — SQL Server alias type Flag';
COMMENT ON COLUMN "HumanResources"."Employee"."rowguid" IS 'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
COMMENT ON COLUMN "HumanResources"."Employee"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "HumanResources"."Employee" IS 'Employee information such as salary, department, and title.';
COMMENT ON COLUMN "HumanResources"."EmployeeDepartmentHistory"."BusinessEntityID" IS 'Employee identification number. Foreign key to Employee.BusinessEntityID.';
COMMENT ON COLUMN "HumanResources"."EmployeeDepartmentHistory"."DepartmentID" IS 'Department in which the employee worked including currently. Foreign key to Department.DepartmentID.';
COMMENT ON COLUMN "HumanResources"."EmployeeDepartmentHistory"."ShiftID" IS 'Identifies which 8-hour shift the employee works. Foreign key to Shift.Shift.ID.';
COMMENT ON COLUMN "HumanResources"."EmployeeDepartmentHistory"."StartDate" IS 'Date the employee started work in the department.';
COMMENT ON COLUMN "HumanResources"."EmployeeDepartmentHistory"."EndDate" IS 'Date the employee left the department. NULL = Current department.';
COMMENT ON COLUMN "HumanResources"."EmployeeDepartmentHistory"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "HumanResources"."EmployeeDepartmentHistory" IS 'Employee department transfers.';
COMMENT ON COLUMN "HumanResources"."EmployeePayHistory"."BusinessEntityID" IS 'Employee identification number. Foreign key to Employee.BusinessEntityID.';
COMMENT ON COLUMN "HumanResources"."EmployeePayHistory"."RateChangeDate" IS 'Date the change in pay is effective';
COMMENT ON COLUMN "HumanResources"."EmployeePayHistory"."Rate" IS 'Salary hourly rate.';
COMMENT ON COLUMN "HumanResources"."EmployeePayHistory"."PayFrequency" IS '1 = Salary received monthly, 2 = Salary received biweekly';
COMMENT ON COLUMN "HumanResources"."EmployeePayHistory"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "HumanResources"."EmployeePayHistory" IS 'Employee pay history.';
COMMENT ON COLUMN "Production"."Illustration"."IllustrationID" IS 'Primary key for Illustration records.';
COMMENT ON COLUMN "Production"."Illustration"."Diagram" IS 'Illustrations used in manufacturing instructions. Stored as XML.';
COMMENT ON COLUMN "Production"."Illustration"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Production"."Illustration" IS 'Bicycle assembly diagrams.';
COMMENT ON COLUMN "HumanResources"."JobCandidate"."JobCandidateID" IS 'Primary key for JobCandidate records.';
COMMENT ON COLUMN "HumanResources"."JobCandidate"."BusinessEntityID" IS 'Employee identification number if applicant was hired. Foreign key to Employee.BusinessEntityID.';
COMMENT ON COLUMN "HumanResources"."JobCandidate"."Resume" IS 'Résumé in XML format.';
COMMENT ON COLUMN "HumanResources"."JobCandidate"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "HumanResources"."JobCandidate" IS 'Résumés submitted to Human Resources by job applicants.';
COMMENT ON COLUMN "Production"."Location"."LocationID" IS 'Primary key for Location records.';
COMMENT ON COLUMN "Production"."Location"."Name" IS 'Location description. — SQL Server alias type Name';
COMMENT ON COLUMN "Production"."Location"."CostRate" IS 'Standard hourly cost of the manufacturing location.';
COMMENT ON COLUMN "Production"."Location"."Availability" IS 'Work capacity (in hours) of the manufacturing location.';
COMMENT ON COLUMN "Production"."Location"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Production"."Location" IS 'Product inventory and manufacturing locations.';
COMMENT ON COLUMN "Person"."Password"."PasswordHash" IS 'Password for the e-mail account.';
COMMENT ON COLUMN "Person"."Password"."PasswordSalt" IS 'Random value concatenated with the password string before the password is hashed.';
COMMENT ON COLUMN "Person"."Password"."rowguid" IS 'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
COMMENT ON COLUMN "Person"."Password"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Person"."Password" IS 'One way hashed authentication information';
COMMENT ON COLUMN "Person"."Person"."BusinessEntityID" IS 'Primary key for Person records.';
COMMENT ON COLUMN "Person"."Person"."PersonType" IS 'Primary type of person: SC = Store Contact, IN = Individual (retail) customer, SP = Sales person, EM = Employee (non-sales), VC = Vendor contact, GC = General contact';
COMMENT ON COLUMN "Person"."Person"."NameStyle" IS '0 = The data in FirstName and LastName are stored in western style (first name, last name) order.  1 = Eastern style (last name, first name) order. — SQL Server alias type NameStyle';
COMMENT ON COLUMN "Person"."Person"."Title" IS 'A courtesy title. For example, Mr. or Ms.';
COMMENT ON COLUMN "Person"."Person"."FirstName" IS 'First name of the person. — SQL Server alias type Name';
COMMENT ON COLUMN "Person"."Person"."MiddleName" IS 'Middle name or middle initial of the person. — SQL Server alias type Name';
COMMENT ON COLUMN "Person"."Person"."LastName" IS 'Last name of the person. — SQL Server alias type Name';
COMMENT ON COLUMN "Person"."Person"."Suffix" IS 'Surname suffix. For example, Sr. or Jr.';
COMMENT ON COLUMN "Person"."Person"."EmailPromotion" IS '0 = Contact does not wish to receive e-mail promotions, 1 = Contact does wish to receive e-mail promotions from AdventureWorks, 2 = Contact does wish to receive e-mail promotions from AdventureWorks and selected partners. ';
COMMENT ON COLUMN "Person"."Person"."AdditionalContactInfo" IS 'Additional contact information about the person stored in xml format. ';
COMMENT ON COLUMN "Person"."Person"."Demographics" IS 'Personal information such as hobbies, and income collected from online shoppers. Used for sales analysis.';
COMMENT ON COLUMN "Person"."Person"."rowguid" IS 'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
COMMENT ON COLUMN "Person"."Person"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Person"."Person" IS 'Human beings involved with AdventureWorks: employees, customer contacts, and vendor contacts.';
COMMENT ON COLUMN "Sales"."PersonCreditCard"."BusinessEntityID" IS 'Business entity identification number. Foreign key to Person.BusinessEntityID.';
COMMENT ON COLUMN "Sales"."PersonCreditCard"."CreditCardID" IS 'Credit card identification number. Foreign key to CreditCard.CreditCardID.';
COMMENT ON COLUMN "Sales"."PersonCreditCard"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Sales"."PersonCreditCard" IS 'Cross-reference table mapping people to their credit card information in the CreditCard table.';
COMMENT ON COLUMN "Person"."PersonPhone"."BusinessEntityID" IS 'Business entity identification number. Foreign key to Person.BusinessEntityID.';
COMMENT ON COLUMN "Person"."PersonPhone"."PhoneNumber" IS 'Telephone number identification number. — SQL Server alias type Phone';
COMMENT ON COLUMN "Person"."PersonPhone"."PhoneNumberTypeID" IS 'Kind of phone number. Foreign key to PhoneNumberType.PhoneNumberTypeID.';
COMMENT ON COLUMN "Person"."PersonPhone"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Person"."PersonPhone" IS 'Telephone number and type of a person.';
COMMENT ON COLUMN "Person"."PhoneNumberType"."PhoneNumberTypeID" IS 'Primary key for telephone number type records.';
COMMENT ON COLUMN "Person"."PhoneNumberType"."Name" IS 'Name of the telephone number type — SQL Server alias type Name';
COMMENT ON COLUMN "Person"."PhoneNumberType"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Person"."PhoneNumberType" IS 'Type of phone number of a person.';
COMMENT ON COLUMN "Production"."Product"."ProductID" IS 'Primary key for Product records.';
COMMENT ON COLUMN "Production"."Product"."Name" IS 'Name of the product. — SQL Server alias type Name';
COMMENT ON COLUMN "Production"."Product"."ProductNumber" IS 'Unique product identification number.';
COMMENT ON COLUMN "Production"."Product"."MakeFlag" IS '0 = Product is purchased, 1 = Product is manufactured in-house. — SQL Server alias type Flag';
COMMENT ON COLUMN "Production"."Product"."FinishedGoodsFlag" IS '0 = Product is not a salable item. 1 = Product is salable. — SQL Server alias type Flag';
COMMENT ON COLUMN "Production"."Product"."Color" IS 'Product color.';
COMMENT ON COLUMN "Production"."Product"."SafetyStockLevel" IS 'Minimum inventory quantity. ';
COMMENT ON COLUMN "Production"."Product"."ReorderPoint" IS 'Inventory level that triggers a purchase order or work order. ';
COMMENT ON COLUMN "Production"."Product"."StandardCost" IS 'Standard cost of the product.';
COMMENT ON COLUMN "Production"."Product"."ListPrice" IS 'Selling price.';
COMMENT ON COLUMN "Production"."Product"."Size" IS 'Product size.';
COMMENT ON COLUMN "Production"."Product"."SizeUnitMeasureCode" IS 'Unit of measure for Size column.';
COMMENT ON COLUMN "Production"."Product"."WeightUnitMeasureCode" IS 'Unit of measure for Weight column.';
COMMENT ON COLUMN "Production"."Product"."Weight" IS 'Product weight.';
COMMENT ON COLUMN "Production"."Product"."DaysToManufacture" IS 'Number of days required to manufacture the product.';
COMMENT ON COLUMN "Production"."Product"."ProductLine" IS 'R = Road, M = Mountain, T = Touring, S = Standard';
COMMENT ON COLUMN "Production"."Product"."Class" IS 'H = High, M = Medium, L = Low';
COMMENT ON COLUMN "Production"."Product"."Style" IS 'W = Womens, M = Mens, U = Universal';
COMMENT ON COLUMN "Production"."Product"."ProductSubcategoryID" IS 'Product is a member of this product subcategory. Foreign key to ProductSubCategory.ProductSubCategoryID. ';
COMMENT ON COLUMN "Production"."Product"."ProductModelID" IS 'Product is a member of this product model. Foreign key to ProductModel.ProductModelID.';
COMMENT ON COLUMN "Production"."Product"."SellStartDate" IS 'Date the product was available for sale.';
COMMENT ON COLUMN "Production"."Product"."SellEndDate" IS 'Date the product was no longer available for sale.';
COMMENT ON COLUMN "Production"."Product"."DiscontinuedDate" IS 'Date the product was discontinued.';
COMMENT ON COLUMN "Production"."Product"."rowguid" IS 'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
COMMENT ON COLUMN "Production"."Product"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Production"."Product" IS 'Products sold or used in the manfacturing of sold products.';
COMMENT ON COLUMN "Production"."ProductCategory"."ProductCategoryID" IS 'Primary key for ProductCategory records.';
COMMENT ON COLUMN "Production"."ProductCategory"."Name" IS 'Category description. — SQL Server alias type Name';
COMMENT ON COLUMN "Production"."ProductCategory"."rowguid" IS 'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
COMMENT ON COLUMN "Production"."ProductCategory"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Production"."ProductCategory" IS 'High-level product categorization.';
COMMENT ON COLUMN "Production"."ProductCostHistory"."ProductID" IS 'Product identification number. Foreign key to Product.ProductID';
COMMENT ON COLUMN "Production"."ProductCostHistory"."StartDate" IS 'Product cost start date.';
COMMENT ON COLUMN "Production"."ProductCostHistory"."EndDate" IS 'Product cost end date.';
COMMENT ON COLUMN "Production"."ProductCostHistory"."StandardCost" IS 'Standard cost of the product.';
COMMENT ON COLUMN "Production"."ProductCostHistory"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Production"."ProductCostHistory" IS 'Changes in the cost of a product over time.';
COMMENT ON COLUMN "Production"."ProductDescription"."ProductDescriptionID" IS 'Primary key for ProductDescription records.';
COMMENT ON COLUMN "Production"."ProductDescription"."Description" IS 'Description of the product.';
COMMENT ON COLUMN "Production"."ProductDescription"."rowguid" IS 'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
COMMENT ON COLUMN "Production"."ProductDescription"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Production"."ProductDescription" IS 'Product descriptions in several languages.';
COMMENT ON COLUMN "Production"."ProductDocument"."ProductID" IS 'Product identification number. Foreign key to Product.ProductID.';
COMMENT ON COLUMN "Production"."ProductDocument"."DocumentNode" IS 'Document identification number. Foreign key to Document.DocumentNode. — SQL Server hierarchyid: a position in a tree, e.g. /1/3/';
COMMENT ON COLUMN "Production"."ProductDocument"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Production"."ProductDocument" IS 'Cross-reference table mapping products to related product documents.';
COMMENT ON COLUMN "Production"."ProductInventory"."ProductID" IS 'Product identification number. Foreign key to Product.ProductID.';
COMMENT ON COLUMN "Production"."ProductInventory"."LocationID" IS 'Inventory location identification number. Foreign key to Location.LocationID. ';
COMMENT ON COLUMN "Production"."ProductInventory"."Shelf" IS 'Storage compartment within an inventory location.';
COMMENT ON COLUMN "Production"."ProductInventory"."Bin" IS 'Storage container on a shelf in an inventory location.';
COMMENT ON COLUMN "Production"."ProductInventory"."Quantity" IS 'Quantity of products in the inventory location.';
COMMENT ON COLUMN "Production"."ProductInventory"."rowguid" IS 'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
COMMENT ON COLUMN "Production"."ProductInventory"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Production"."ProductInventory" IS 'Product inventory information.';
COMMENT ON COLUMN "Production"."ProductListPriceHistory"."ProductID" IS 'Product identification number. Foreign key to Product.ProductID';
COMMENT ON COLUMN "Production"."ProductListPriceHistory"."StartDate" IS 'List price start date.';
COMMENT ON COLUMN "Production"."ProductListPriceHistory"."EndDate" IS 'List price end date';
COMMENT ON COLUMN "Production"."ProductListPriceHistory"."ListPrice" IS 'Product list price.';
COMMENT ON COLUMN "Production"."ProductListPriceHistory"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Production"."ProductListPriceHistory" IS 'Changes in the list price of a product over time.';
COMMENT ON COLUMN "Production"."ProductModel"."ProductModelID" IS 'Primary key for ProductModel records.';
COMMENT ON COLUMN "Production"."ProductModel"."Name" IS 'Product model description. — SQL Server alias type Name';
COMMENT ON COLUMN "Production"."ProductModel"."CatalogDescription" IS 'Detailed product catalog information in xml format.';
COMMENT ON COLUMN "Production"."ProductModel"."Instructions" IS 'Manufacturing instructions in xml format.';
COMMENT ON COLUMN "Production"."ProductModel"."rowguid" IS 'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
COMMENT ON COLUMN "Production"."ProductModel"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Production"."ProductModel" IS 'Product model classification.';
COMMENT ON COLUMN "Production"."ProductModelIllustration"."ProductModelID" IS 'Primary key. Foreign key to ProductModel.ProductModelID.';
COMMENT ON COLUMN "Production"."ProductModelIllustration"."IllustrationID" IS 'Primary key. Foreign key to Illustration.IllustrationID.';
COMMENT ON COLUMN "Production"."ProductModelIllustration"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Production"."ProductModelIllustration" IS 'Cross-reference table mapping product models and illustrations.';
COMMENT ON COLUMN "Production"."ProductModelProductDescriptionCulture"."ProductModelID" IS 'Primary key. Foreign key to ProductModel.ProductModelID.';
COMMENT ON COLUMN "Production"."ProductModelProductDescriptionCulture"."ProductDescriptionID" IS 'Primary key. Foreign key to ProductDescription.ProductDescriptionID.';
COMMENT ON COLUMN "Production"."ProductModelProductDescriptionCulture"."CultureID" IS 'Culture identification number. Foreign key to Culture.CultureID.';
COMMENT ON COLUMN "Production"."ProductModelProductDescriptionCulture"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Production"."ProductModelProductDescriptionCulture" IS 'Cross-reference table mapping product descriptions and the language the description is written in.';
COMMENT ON COLUMN "Production"."ProductPhoto"."ProductPhotoID" IS 'Primary key for ProductPhoto records.';
COMMENT ON COLUMN "Production"."ProductPhoto"."ThumbNailPhoto" IS 'Small image of the product.';
COMMENT ON COLUMN "Production"."ProductPhoto"."ThumbnailPhotoFileName" IS 'Small image file name.';
COMMENT ON COLUMN "Production"."ProductPhoto"."LargePhoto" IS 'Large image of the product.';
COMMENT ON COLUMN "Production"."ProductPhoto"."LargePhotoFileName" IS 'Large image file name.';
COMMENT ON COLUMN "Production"."ProductPhoto"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Production"."ProductPhoto" IS 'Product images.';
COMMENT ON COLUMN "Production"."ProductProductPhoto"."ProductID" IS 'Product identification number. Foreign key to Product.ProductID.';
COMMENT ON COLUMN "Production"."ProductProductPhoto"."ProductPhotoID" IS 'Product photo identification number. Foreign key to ProductPhoto.ProductPhotoID.';
COMMENT ON COLUMN "Production"."ProductProductPhoto"."Primary" IS '0 = Photo is not the principal image. 1 = Photo is the principal image. — SQL Server alias type Flag';
COMMENT ON COLUMN "Production"."ProductProductPhoto"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Production"."ProductProductPhoto" IS 'Cross-reference table mapping products and product photos.';
COMMENT ON COLUMN "Production"."ProductReview"."ProductReviewID" IS 'Primary key for ProductReview records.';
COMMENT ON COLUMN "Production"."ProductReview"."ProductID" IS 'Product identification number. Foreign key to Product.ProductID.';
COMMENT ON COLUMN "Production"."ProductReview"."ReviewerName" IS 'Name of the reviewer. — SQL Server alias type Name';
COMMENT ON COLUMN "Production"."ProductReview"."ReviewDate" IS 'Date review was submitted.';
COMMENT ON COLUMN "Production"."ProductReview"."EmailAddress" IS 'Reviewer''s e-mail address.';
COMMENT ON COLUMN "Production"."ProductReview"."Rating" IS 'Product rating given by the reviewer. Scale is 1 to 5 with 5 as the highest rating.';
COMMENT ON COLUMN "Production"."ProductReview"."Comments" IS 'Reviewer''s comments';
COMMENT ON COLUMN "Production"."ProductReview"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Production"."ProductReview" IS 'Customer reviews of products they have purchased.';
COMMENT ON COLUMN "Production"."ProductSubcategory"."ProductSubcategoryID" IS 'Primary key for ProductSubcategory records.';
COMMENT ON COLUMN "Production"."ProductSubcategory"."ProductCategoryID" IS 'Product category identification number. Foreign key to ProductCategory.ProductCategoryID.';
COMMENT ON COLUMN "Production"."ProductSubcategory"."Name" IS 'Subcategory description. — SQL Server alias type Name';
COMMENT ON COLUMN "Production"."ProductSubcategory"."rowguid" IS 'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
COMMENT ON COLUMN "Production"."ProductSubcategory"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Production"."ProductSubcategory" IS 'Product subcategories. See ProductCategory table.';
COMMENT ON COLUMN "Purchasing"."ProductVendor"."ProductID" IS 'Primary key. Foreign key to Product.ProductID.';
COMMENT ON COLUMN "Purchasing"."ProductVendor"."BusinessEntityID" IS 'Primary key. Foreign key to Vendor.BusinessEntityID.';
COMMENT ON COLUMN "Purchasing"."ProductVendor"."AverageLeadTime" IS 'The average span of time (in days) between placing an order with the vendor and receiving the purchased product.';
COMMENT ON COLUMN "Purchasing"."ProductVendor"."StandardPrice" IS 'The vendor''s usual selling price.';
COMMENT ON COLUMN "Purchasing"."ProductVendor"."LastReceiptCost" IS 'The selling price when last purchased.';
COMMENT ON COLUMN "Purchasing"."ProductVendor"."LastReceiptDate" IS 'Date the product was last received by the vendor.';
COMMENT ON COLUMN "Purchasing"."ProductVendor"."MinOrderQty" IS 'The maximum quantity that should be ordered.';
COMMENT ON COLUMN "Purchasing"."ProductVendor"."MaxOrderQty" IS 'The minimum quantity that should be ordered.';
COMMENT ON COLUMN "Purchasing"."ProductVendor"."OnOrderQty" IS 'The quantity currently on order.';
COMMENT ON COLUMN "Purchasing"."ProductVendor"."UnitMeasureCode" IS 'The product''s unit of measure.';
COMMENT ON COLUMN "Purchasing"."ProductVendor"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Purchasing"."ProductVendor" IS 'Cross-reference table mapping vendors with the products they supply.';
COMMENT ON COLUMN "Purchasing"."PurchaseOrderDetail"."PurchaseOrderID" IS 'Primary key. Foreign key to PurchaseOrderHeader.PurchaseOrderID.';
COMMENT ON COLUMN "Purchasing"."PurchaseOrderDetail"."PurchaseOrderDetailID" IS 'Primary key. One line number per purchased product.';
COMMENT ON COLUMN "Purchasing"."PurchaseOrderDetail"."DueDate" IS 'Date the product is expected to be received.';
COMMENT ON COLUMN "Purchasing"."PurchaseOrderDetail"."OrderQty" IS 'Quantity ordered.';
COMMENT ON COLUMN "Purchasing"."PurchaseOrderDetail"."ProductID" IS 'Product identification number. Foreign key to Product.ProductID.';
COMMENT ON COLUMN "Purchasing"."PurchaseOrderDetail"."UnitPrice" IS 'Vendor''s selling price of a single product.';
COMMENT ON COLUMN "Purchasing"."PurchaseOrderDetail"."LineTotal" IS 'Per product subtotal. Computed as OrderQty * UnitPrice. — Computed in SQL Server: OrderQty * UnitPrice';
COMMENT ON COLUMN "Purchasing"."PurchaseOrderDetail"."ReceivedQty" IS 'Quantity actually received from the vendor.';
COMMENT ON COLUMN "Purchasing"."PurchaseOrderDetail"."RejectedQty" IS 'Quantity rejected during inspection.';
COMMENT ON COLUMN "Purchasing"."PurchaseOrderDetail"."StockedQty" IS 'Quantity accepted into inventory. Computed as ReceivedQty - RejectedQty. — Computed in SQL Server: ReceivedQty - RejectedQty';
COMMENT ON COLUMN "Purchasing"."PurchaseOrderDetail"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Purchasing"."PurchaseOrderDetail" IS 'Individual products associated with a specific purchase order. See PurchaseOrderHeader.';
COMMENT ON COLUMN "Purchasing"."PurchaseOrderHeader"."PurchaseOrderID" IS 'Primary key.';
COMMENT ON COLUMN "Purchasing"."PurchaseOrderHeader"."RevisionNumber" IS 'Incremental number to track changes to the purchase order over time.';
COMMENT ON COLUMN "Purchasing"."PurchaseOrderHeader"."Status" IS 'Order current status. 1 = Pending; 2 = Approved; 3 = Rejected; 4 = Complete';
COMMENT ON COLUMN "Purchasing"."PurchaseOrderHeader"."EmployeeID" IS 'Employee who created the purchase order. Foreign key to Employee.BusinessEntityID.';
COMMENT ON COLUMN "Purchasing"."PurchaseOrderHeader"."VendorID" IS 'Vendor with whom the purchase order is placed. Foreign key to Vendor.BusinessEntityID.';
COMMENT ON COLUMN "Purchasing"."PurchaseOrderHeader"."ShipMethodID" IS 'Shipping method. Foreign key to ShipMethod.ShipMethodID.';
COMMENT ON COLUMN "Purchasing"."PurchaseOrderHeader"."OrderDate" IS 'Purchase order creation date.';
COMMENT ON COLUMN "Purchasing"."PurchaseOrderHeader"."ShipDate" IS 'Estimated shipment date from the vendor.';
COMMENT ON COLUMN "Purchasing"."PurchaseOrderHeader"."SubTotal" IS 'Purchase order subtotal. Computed as SUM(PurchaseOrderDetail.LineTotal)for the appropriate PurchaseOrderID.';
COMMENT ON COLUMN "Purchasing"."PurchaseOrderHeader"."TaxAmt" IS 'Tax amount.';
COMMENT ON COLUMN "Purchasing"."PurchaseOrderHeader"."Freight" IS 'Shipping cost.';
COMMENT ON COLUMN "Purchasing"."PurchaseOrderHeader"."TotalDue" IS 'Total due to vendor. Computed as Subtotal + TaxAmt + Freight. — Computed in SQL Server: SubTotal + TaxAmt + Freight';
COMMENT ON COLUMN "Purchasing"."PurchaseOrderHeader"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Purchasing"."PurchaseOrderHeader" IS 'General purchase order information. See PurchaseOrderDetail.';
COMMENT ON COLUMN "Sales"."SalesOrderDetail"."SalesOrderID" IS 'Primary key. Foreign key to SalesOrderHeader.SalesOrderID.';
COMMENT ON COLUMN "Sales"."SalesOrderDetail"."SalesOrderDetailID" IS 'Primary key. One incremental unique number per product sold.';
COMMENT ON COLUMN "Sales"."SalesOrderDetail"."CarrierTrackingNumber" IS 'Shipment tracking number supplied by the shipper.';
COMMENT ON COLUMN "Sales"."SalesOrderDetail"."OrderQty" IS 'Quantity ordered per product.';
COMMENT ON COLUMN "Sales"."SalesOrderDetail"."ProductID" IS 'Product sold to customer. Foreign key to Product.ProductID.';
COMMENT ON COLUMN "Sales"."SalesOrderDetail"."SpecialOfferID" IS 'Promotional code. Foreign key to SpecialOffer.SpecialOfferID.';
COMMENT ON COLUMN "Sales"."SalesOrderDetail"."UnitPrice" IS 'Selling price of a single product.';
COMMENT ON COLUMN "Sales"."SalesOrderDetail"."UnitPriceDiscount" IS 'Discount amount.';
COMMENT ON COLUMN "Sales"."SalesOrderDetail"."LineTotal" IS 'Per product subtotal. Computed as UnitPrice * (1 - UnitPriceDiscount) * OrderQty. — Computed in SQL Server: UnitPrice * (1 - UnitPriceDiscount) * OrderQty';
COMMENT ON COLUMN "Sales"."SalesOrderDetail"."rowguid" IS 'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
COMMENT ON COLUMN "Sales"."SalesOrderDetail"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Sales"."SalesOrderDetail" IS 'Individual products associated with a specific sales order. See SalesOrderHeader.';
COMMENT ON COLUMN "Sales"."SalesOrderHeader"."SalesOrderID" IS 'Primary key.';
COMMENT ON COLUMN "Sales"."SalesOrderHeader"."RevisionNumber" IS 'Incremental number to track changes to the sales order over time.';
COMMENT ON COLUMN "Sales"."SalesOrderHeader"."OrderDate" IS 'Dates the sales order was created.';
COMMENT ON COLUMN "Sales"."SalesOrderHeader"."DueDate" IS 'Date the order is due to the customer.';
COMMENT ON COLUMN "Sales"."SalesOrderHeader"."ShipDate" IS 'Date the order was shipped to the customer.';
COMMENT ON COLUMN "Sales"."SalesOrderHeader"."Status" IS 'Order current status. 1 = In process; 2 = Approved; 3 = Backordered; 4 = Rejected; 5 = Shipped; 6 = Cancelled';
COMMENT ON COLUMN "Sales"."SalesOrderHeader"."OnlineOrderFlag" IS '0 = Order placed by sales person. 1 = Order placed online by customer. — SQL Server alias type Flag';
COMMENT ON COLUMN "Sales"."SalesOrderHeader"."SalesOrderNumber" IS 'Unique sales order identification number. — Computed in SQL Server: ''SO'' + SalesOrderID';
COMMENT ON COLUMN "Sales"."SalesOrderHeader"."PurchaseOrderNumber" IS 'Customer purchase order number reference.  — SQL Server alias type OrderNumber';
COMMENT ON COLUMN "Sales"."SalesOrderHeader"."AccountNumber" IS 'Financial accounting number reference. — SQL Server alias type AccountNumber';
COMMENT ON COLUMN "Sales"."SalesOrderHeader"."CustomerID" IS 'Customer identification number. Foreign key to Customer.BusinessEntityID.';
COMMENT ON COLUMN "Sales"."SalesOrderHeader"."SalesPersonID" IS 'Sales person who created the sales order. Foreign key to SalesPerson.BusinessEntityID.';
COMMENT ON COLUMN "Sales"."SalesOrderHeader"."TerritoryID" IS 'Territory in which the sale was made. Foreign key to SalesTerritory.SalesTerritoryID.';
COMMENT ON COLUMN "Sales"."SalesOrderHeader"."BillToAddressID" IS 'Customer billing address. Foreign key to Address.AddressID.';
COMMENT ON COLUMN "Sales"."SalesOrderHeader"."ShipToAddressID" IS 'Customer shipping address. Foreign key to Address.AddressID.';
COMMENT ON COLUMN "Sales"."SalesOrderHeader"."ShipMethodID" IS 'Shipping method. Foreign key to ShipMethod.ShipMethodID.';
COMMENT ON COLUMN "Sales"."SalesOrderHeader"."CreditCardID" IS 'Credit card identification number. Foreign key to CreditCard.CreditCardID.';
COMMENT ON COLUMN "Sales"."SalesOrderHeader"."CreditCardApprovalCode" IS 'Approval code provided by the credit card company.';
COMMENT ON COLUMN "Sales"."SalesOrderHeader"."CurrencyRateID" IS 'Currency exchange rate used. Foreign key to CurrencyRate.CurrencyRateID.';
COMMENT ON COLUMN "Sales"."SalesOrderHeader"."SubTotal" IS 'Sales subtotal. Computed as SUM(SalesOrderDetail.LineTotal)for the appropriate SalesOrderID.';
COMMENT ON COLUMN "Sales"."SalesOrderHeader"."TaxAmt" IS 'Tax amount.';
COMMENT ON COLUMN "Sales"."SalesOrderHeader"."Freight" IS 'Shipping cost.';
COMMENT ON COLUMN "Sales"."SalesOrderHeader"."TotalDue" IS 'Total due from customer. Computed as Subtotal + TaxAmt + Freight. — Computed in SQL Server: SubTotal + TaxAmt + Freight';
COMMENT ON COLUMN "Sales"."SalesOrderHeader"."Comment" IS 'Sales representative comments.';
COMMENT ON COLUMN "Sales"."SalesOrderHeader"."rowguid" IS 'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
COMMENT ON COLUMN "Sales"."SalesOrderHeader"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Sales"."SalesOrderHeader" IS 'General sales order information.';
COMMENT ON COLUMN "Sales"."SalesOrderHeaderSalesReason"."SalesOrderID" IS 'Primary key. Foreign key to SalesOrderHeader.SalesOrderID.';
COMMENT ON COLUMN "Sales"."SalesOrderHeaderSalesReason"."SalesReasonID" IS 'Primary key. Foreign key to SalesReason.SalesReasonID.';
COMMENT ON COLUMN "Sales"."SalesOrderHeaderSalesReason"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Sales"."SalesOrderHeaderSalesReason" IS 'Cross-reference table mapping sales orders to sales reason codes.';
COMMENT ON COLUMN "Sales"."SalesPerson"."BusinessEntityID" IS 'Primary key for SalesPerson records. Foreign key to Employee.BusinessEntityID';
COMMENT ON COLUMN "Sales"."SalesPerson"."TerritoryID" IS 'Territory currently assigned to. Foreign key to SalesTerritory.SalesTerritoryID.';
COMMENT ON COLUMN "Sales"."SalesPerson"."SalesQuota" IS 'Projected yearly sales.';
COMMENT ON COLUMN "Sales"."SalesPerson"."Bonus" IS 'Bonus due if quota is met.';
COMMENT ON COLUMN "Sales"."SalesPerson"."CommissionPct" IS 'Commision percent received per sale.';
COMMENT ON COLUMN "Sales"."SalesPerson"."SalesYTD" IS 'Sales total year to date.';
COMMENT ON COLUMN "Sales"."SalesPerson"."SalesLastYear" IS 'Sales total of previous year.';
COMMENT ON COLUMN "Sales"."SalesPerson"."rowguid" IS 'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
COMMENT ON COLUMN "Sales"."SalesPerson"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Sales"."SalesPerson" IS 'Sales representative current information.';
COMMENT ON COLUMN "Sales"."SalesPersonQuotaHistory"."BusinessEntityID" IS 'Sales person identification number. Foreign key to SalesPerson.BusinessEntityID.';
COMMENT ON COLUMN "Sales"."SalesPersonQuotaHistory"."QuotaDate" IS 'Sales quota date.';
COMMENT ON COLUMN "Sales"."SalesPersonQuotaHistory"."SalesQuota" IS 'Sales quota amount.';
COMMENT ON COLUMN "Sales"."SalesPersonQuotaHistory"."rowguid" IS 'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
COMMENT ON COLUMN "Sales"."SalesPersonQuotaHistory"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Sales"."SalesPersonQuotaHistory" IS 'Sales performance tracking.';
COMMENT ON COLUMN "Sales"."SalesReason"."SalesReasonID" IS 'Primary key for SalesReason records.';
COMMENT ON COLUMN "Sales"."SalesReason"."Name" IS 'Sales reason description. — SQL Server alias type Name';
COMMENT ON COLUMN "Sales"."SalesReason"."ReasonType" IS 'Category the sales reason belongs to. — SQL Server alias type Name';
COMMENT ON COLUMN "Sales"."SalesReason"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Sales"."SalesReason" IS 'Lookup table of customer purchase reasons.';
COMMENT ON COLUMN "Sales"."SalesTaxRate"."SalesTaxRateID" IS 'Primary key for SalesTaxRate records.';
COMMENT ON COLUMN "Sales"."SalesTaxRate"."StateProvinceID" IS 'State, province, or country/region the sales tax applies to.';
COMMENT ON COLUMN "Sales"."SalesTaxRate"."TaxType" IS '1 = Tax applied to retail transactions, 2 = Tax applied to wholesale transactions, 3 = Tax applied to all sales (retail and wholesale) transactions.';
COMMENT ON COLUMN "Sales"."SalesTaxRate"."TaxRate" IS 'Tax rate amount.';
COMMENT ON COLUMN "Sales"."SalesTaxRate"."Name" IS 'Tax rate description. — SQL Server alias type Name';
COMMENT ON COLUMN "Sales"."SalesTaxRate"."rowguid" IS 'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
COMMENT ON COLUMN "Sales"."SalesTaxRate"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Sales"."SalesTaxRate" IS 'Tax rate lookup table.';
COMMENT ON COLUMN "Sales"."SalesTerritory"."TerritoryID" IS 'Primary key for SalesTerritory records.';
COMMENT ON COLUMN "Sales"."SalesTerritory"."Name" IS 'Sales territory description — SQL Server alias type Name';
COMMENT ON COLUMN "Sales"."SalesTerritory"."CountryRegionCode" IS 'ISO standard country or region code. Foreign key to CountryRegion.CountryRegionCode. ';
COMMENT ON COLUMN "Sales"."SalesTerritory"."Group" IS 'Geographic area to which the sales territory belong.';
COMMENT ON COLUMN "Sales"."SalesTerritory"."SalesYTD" IS 'Sales in the territory year to date.';
COMMENT ON COLUMN "Sales"."SalesTerritory"."SalesLastYear" IS 'Sales in the territory the previous year.';
COMMENT ON COLUMN "Sales"."SalesTerritory"."CostYTD" IS 'Business costs in the territory year to date.';
COMMENT ON COLUMN "Sales"."SalesTerritory"."CostLastYear" IS 'Business costs in the territory the previous year.';
COMMENT ON COLUMN "Sales"."SalesTerritory"."rowguid" IS 'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
COMMENT ON COLUMN "Sales"."SalesTerritory"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Sales"."SalesTerritory" IS 'Sales territory lookup table.';
COMMENT ON COLUMN "Sales"."SalesTerritoryHistory"."BusinessEntityID" IS 'Primary key. The sales rep.  Foreign key to SalesPerson.BusinessEntityID.';
COMMENT ON COLUMN "Sales"."SalesTerritoryHistory"."TerritoryID" IS 'Primary key. Territory identification number. Foreign key to SalesTerritory.SalesTerritoryID.';
COMMENT ON COLUMN "Sales"."SalesTerritoryHistory"."StartDate" IS 'Primary key. Date the sales representive started work in the territory.';
COMMENT ON COLUMN "Sales"."SalesTerritoryHistory"."EndDate" IS 'Date the sales representative left work in the territory.';
COMMENT ON COLUMN "Sales"."SalesTerritoryHistory"."rowguid" IS 'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
COMMENT ON COLUMN "Sales"."SalesTerritoryHistory"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Sales"."SalesTerritoryHistory" IS 'Sales representative transfers to other sales territories.';
COMMENT ON COLUMN "Production"."ScrapReason"."ScrapReasonID" IS 'Primary key for ScrapReason records.';
COMMENT ON COLUMN "Production"."ScrapReason"."Name" IS 'Failure description. — SQL Server alias type Name';
COMMENT ON COLUMN "Production"."ScrapReason"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Production"."ScrapReason" IS 'Manufacturing failure reasons lookup table.';
COMMENT ON COLUMN "HumanResources"."Shift"."ShiftID" IS 'Primary key for Shift records.';
COMMENT ON COLUMN "HumanResources"."Shift"."Name" IS 'Shift description. — SQL Server alias type Name';
COMMENT ON COLUMN "HumanResources"."Shift"."StartTime" IS 'Shift start time.';
COMMENT ON COLUMN "HumanResources"."Shift"."EndTime" IS 'Shift end time.';
COMMENT ON COLUMN "HumanResources"."Shift"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "HumanResources"."Shift" IS 'Work shift lookup table.';
COMMENT ON COLUMN "Purchasing"."ShipMethod"."ShipMethodID" IS 'Primary key for ShipMethod records.';
COMMENT ON COLUMN "Purchasing"."ShipMethod"."Name" IS 'Shipping company name. — SQL Server alias type Name';
COMMENT ON COLUMN "Purchasing"."ShipMethod"."ShipBase" IS 'Minimum shipping charge.';
COMMENT ON COLUMN "Purchasing"."ShipMethod"."ShipRate" IS 'Shipping charge per pound.';
COMMENT ON COLUMN "Purchasing"."ShipMethod"."rowguid" IS 'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
COMMENT ON COLUMN "Purchasing"."ShipMethod"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Purchasing"."ShipMethod" IS 'Shipping company lookup table.';
COMMENT ON COLUMN "Sales"."ShoppingCartItem"."ShoppingCartItemID" IS 'Primary key for ShoppingCartItem records.';
COMMENT ON COLUMN "Sales"."ShoppingCartItem"."ShoppingCartID" IS 'Shopping cart identification number.';
COMMENT ON COLUMN "Sales"."ShoppingCartItem"."Quantity" IS 'Product quantity ordered.';
COMMENT ON COLUMN "Sales"."ShoppingCartItem"."ProductID" IS 'Product ordered. Foreign key to Product.ProductID.';
COMMENT ON COLUMN "Sales"."ShoppingCartItem"."DateCreated" IS 'Date the time the record was created.';
COMMENT ON COLUMN "Sales"."ShoppingCartItem"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Sales"."ShoppingCartItem" IS 'Contains online customer orders until the order is submitted or cancelled.';
COMMENT ON COLUMN "Sales"."SpecialOffer"."SpecialOfferID" IS 'Primary key for SpecialOffer records.';
COMMENT ON COLUMN "Sales"."SpecialOffer"."Description" IS 'Discount description.';
COMMENT ON COLUMN "Sales"."SpecialOffer"."DiscountPct" IS 'Discount precentage.';
COMMENT ON COLUMN "Sales"."SpecialOffer"."Type" IS 'Discount type category.';
COMMENT ON COLUMN "Sales"."SpecialOffer"."Category" IS 'Group the discount applies to such as Reseller or Customer.';
COMMENT ON COLUMN "Sales"."SpecialOffer"."StartDate" IS 'Discount start date.';
COMMENT ON COLUMN "Sales"."SpecialOffer"."EndDate" IS 'Discount end date.';
COMMENT ON COLUMN "Sales"."SpecialOffer"."MinQty" IS 'Minimum discount percent allowed.';
COMMENT ON COLUMN "Sales"."SpecialOffer"."MaxQty" IS 'Maximum discount percent allowed.';
COMMENT ON COLUMN "Sales"."SpecialOffer"."rowguid" IS 'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
COMMENT ON COLUMN "Sales"."SpecialOffer"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Sales"."SpecialOffer" IS 'Sale discounts lookup table.';
COMMENT ON COLUMN "Sales"."SpecialOfferProduct"."SpecialOfferID" IS 'Primary key for SpecialOfferProduct records.';
COMMENT ON COLUMN "Sales"."SpecialOfferProduct"."ProductID" IS 'Product identification number. Foreign key to Product.ProductID.';
COMMENT ON COLUMN "Sales"."SpecialOfferProduct"."rowguid" IS 'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
COMMENT ON COLUMN "Sales"."SpecialOfferProduct"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Sales"."SpecialOfferProduct" IS 'Cross-reference table mapping products to special offer discounts.';
COMMENT ON COLUMN "Person"."StateProvince"."StateProvinceID" IS 'Primary key for StateProvince records.';
COMMENT ON COLUMN "Person"."StateProvince"."StateProvinceCode" IS 'ISO standard state or province code.';
COMMENT ON COLUMN "Person"."StateProvince"."CountryRegionCode" IS 'ISO standard country or region code. Foreign key to CountryRegion.CountryRegionCode. ';
COMMENT ON COLUMN "Person"."StateProvince"."IsOnlyStateProvinceFlag" IS '0 = StateProvinceCode exists. 1 = StateProvinceCode unavailable, using CountryRegionCode. — SQL Server alias type Flag';
COMMENT ON COLUMN "Person"."StateProvince"."Name" IS 'State or province description. — SQL Server alias type Name';
COMMENT ON COLUMN "Person"."StateProvince"."TerritoryID" IS 'ID of the territory in which the state or province is located. Foreign key to SalesTerritory.SalesTerritoryID.';
COMMENT ON COLUMN "Person"."StateProvince"."rowguid" IS 'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
COMMENT ON COLUMN "Person"."StateProvince"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Person"."StateProvince" IS 'State and province lookup table.';
COMMENT ON COLUMN "Sales"."Store"."BusinessEntityID" IS 'Primary key. Foreign key to Customer.BusinessEntityID.';
COMMENT ON COLUMN "Sales"."Store"."Name" IS 'Name of the store. — SQL Server alias type Name';
COMMENT ON COLUMN "Sales"."Store"."SalesPersonID" IS 'ID of the sales person assigned to the customer. Foreign key to SalesPerson.BusinessEntityID.';
COMMENT ON COLUMN "Sales"."Store"."Demographics" IS 'Demographic informationg about the store such as the number of employees, annual sales and store type.';
COMMENT ON COLUMN "Sales"."Store"."rowguid" IS 'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.';
COMMENT ON COLUMN "Sales"."Store"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Sales"."Store" IS 'Customers (resellers) of Adventure Works products.';
COMMENT ON COLUMN "Production"."TransactionHistory"."TransactionID" IS 'Primary key for TransactionHistory records.';
COMMENT ON COLUMN "Production"."TransactionHistory"."ProductID" IS 'Product identification number. Foreign key to Product.ProductID.';
COMMENT ON COLUMN "Production"."TransactionHistory"."ReferenceOrderID" IS 'Purchase order, sales order, or work order identification number.';
COMMENT ON COLUMN "Production"."TransactionHistory"."ReferenceOrderLineID" IS 'Line number associated with the purchase order, sales order, or work order.';
COMMENT ON COLUMN "Production"."TransactionHistory"."TransactionDate" IS 'Date and time of the transaction.';
COMMENT ON COLUMN "Production"."TransactionHistory"."TransactionType" IS 'W = WorkOrder, S = SalesOrder, P = PurchaseOrder';
COMMENT ON COLUMN "Production"."TransactionHistory"."Quantity" IS 'Product quantity.';
COMMENT ON COLUMN "Production"."TransactionHistory"."ActualCost" IS 'Product cost.';
COMMENT ON COLUMN "Production"."TransactionHistory"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Production"."TransactionHistory" IS 'Record of each purchase order, sales order, or work order transaction year to date.';
COMMENT ON COLUMN "Production"."TransactionHistoryArchive"."TransactionID" IS 'Primary key for TransactionHistoryArchive records.';
COMMENT ON COLUMN "Production"."TransactionHistoryArchive"."ProductID" IS 'Product identification number. Foreign key to Product.ProductID.';
COMMENT ON COLUMN "Production"."TransactionHistoryArchive"."ReferenceOrderID" IS 'Purchase order, sales order, or work order identification number.';
COMMENT ON COLUMN "Production"."TransactionHistoryArchive"."ReferenceOrderLineID" IS 'Line number associated with the purchase order, sales order, or work order.';
COMMENT ON COLUMN "Production"."TransactionHistoryArchive"."TransactionDate" IS 'Date and time of the transaction.';
COMMENT ON COLUMN "Production"."TransactionHistoryArchive"."TransactionType" IS 'W = Work Order, S = Sales Order, P = Purchase Order';
COMMENT ON COLUMN "Production"."TransactionHistoryArchive"."Quantity" IS 'Product quantity.';
COMMENT ON COLUMN "Production"."TransactionHistoryArchive"."ActualCost" IS 'Product cost.';
COMMENT ON COLUMN "Production"."TransactionHistoryArchive"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Production"."TransactionHistoryArchive" IS 'Transactions for previous years.';
COMMENT ON COLUMN "Production"."UnitMeasure"."UnitMeasureCode" IS 'Primary key.';
COMMENT ON COLUMN "Production"."UnitMeasure"."Name" IS 'Unit of measure description. — SQL Server alias type Name';
COMMENT ON COLUMN "Production"."UnitMeasure"."ModifiedDate" IS 'Date and time the record was last updated.';
COMMENT ON TABLE "Production"."UnitMeasure" IS 'Unit of measure lookup table.';
COMMENT ON COLUMN "Purchasing"."Vendor"."BusinessEntityID" IS 'Primary key for Vendor records.  Foreign key to BusinessEntity.BusinessEntityID';
COMMENT ON COLUMN "Purchasing"."Vendor"."AccountNumber" IS 'Vendor account (identification) number. — SQL Server alias type AccountNumber';
COMMENT ON COLUMN "Purchasing"."Vendor"."Name" IS 'Company name. — SQL Server alias type Name';
COMMENT ON COLUMN "Purchasing"."Vendor"."CreditRating" IS '1 = Superior, 2 = Excellent, 3 = Above average, 4 = Average, 5 = Below average';
COMMENT ON COLUMN "Purchasing"."Vendor"."PreferredVendorStatus" IS '0 = Do not use if another vendor is available. 1 = Preferred over other vendors supplying the same product. — SQL Server alias type Flag';
COMMENT ON COLUMN "Purchasing"."Vendor"."ActiveFlag" IS '0 = Vendor no longer used. 1 = Vendor is actively used. — SQL Server alias type Flag';
COMMENT ON TABLE "Purchasing"."Vendor" IS 'Companies from whom Adventure Works Cycles purchases parts or other goods.';
COMMENT ON COLUMN "Production"."WorkOrder"."StockedQty" IS 'Computed in SQL Server: OrderQty - ScrappedQty';

FAQ

Where do I download the AdventureWorks database?

From Microsoft. Microsoft Learn links .bak backups for SQL Server 2008 R2 to 2025. The scripts that build it live in the sql-server-samples repository on GitHub under the MIT license. The SQL on this page is the same schema, rendered for PostgreSQL by our parser from Microsoft’s instawdb.sql. Tables, keys and column notes are unchanged.

How many tables does AdventureWorks have?

Seventy-one in the OLTP version. Three of them sit in dbo and only log the database itself: build version, errors and DDL changes. So diagrams, including this one, show the 68 in Person, HumanResources, Production, Purchasing and Sales. AdventureWorksLT is a separate, lighter sample with about a dozen tables.

What changed in the PostgreSQL version of the schema?

Types only. hierarchyid and geography become text, uniqueidentifier becomes uuid, money becomes numeric, and the alias types Name, Flag and Phone become their base types. Computed columns such as TotalDue are kept as ordinary columns, and their notes say how SQL Server computes them.

More example schemas