text: ﻿
  -- ----------------------------------------------------------------------------------------------------------------
  -- Generated by LLBLGen Pro v3.1  Build: September 30th, 2011
  -- Firebird 1.5/2.x DDL Script generated from project: AdventureWorks
  -- Project filename: C:\Projects\NetIndustry\LlblGenTraining\AdventureWorks\AdventureWorks.Dal\AdventureWorks.llblgenproj
  -- Script generated on: 11-Dec-2011 22:59.39
  --
  -- This is an Update script for updating an existing data model to a newer version. If you want DDL SQL for a new model,
  -- please create a Create script instead. 
  --
  -- This script might create schemas, which requires you to assign a proper user to the schema. Adjust the CREATE SCHEMA
  -- statements below, if any, to avoid errors at runtime.
  --
  -- Please run the scripts in the right order, use the timestamp in the filename and inside this script for that.
  -- This script might need adjustment in some statements. You should consider this script as a starting point for
  -- upgrading the existing data model.
  -- ----------------------------------------------------------------------------------------------------------------
  -- ###############################################################################################################
  -- Drop constraints referring to elements which are changed in this script (constraints are recreated later on)
  -- ###############################################################################################################
  
  -- ###############################################################################################################
  -- Rename statements
  -- ###############################################################################################################
  
  -- ###############################################################################################################
  -- DROP statements for elements no longer needed or replaced elements.
  -- ###############################################################################################################
  
  -- ###############################################################################################################
  -- ADD statements for new elements (except FK/UC)
  -- ###############################################################################################################
  
  CREATE TABLE "Address"
  (
  	"AddressId" INTEGER NOT NULL, 
  	"AddressLine1" VARCHAR(60) NOT NULL, 
  	"AddressLine2" VARCHAR(60), 
  	"City" VARCHAR(30) NOT NULL, 
  	"ModifiedDate" DATE NOT NULL, 
  	"PostalCode" VARCHAR(15) NOT NULL, 
  	"StateProvinceId" INTEGER NOT NULL 
  );
  
  CREATE TABLE "AddressType"
  (
  	"AddressTypeId" INTEGER NOT NULL, 
  	"ModifiedDate" DATE NOT NULL, 
  	"Name" VARCHAR(50) NOT NULL 
  );
  
  CREATE TABLE "BillOfMaterial"
  (
  	"BillOfMaterialsId" INTEGER NOT NULL, 
  	"Bomlevel" SMALLINT NOT NULL, 
  	"ComponentId" INTEGER NOT NULL, 
  	"EndDate" DATE, 
  	"ModifiedDate" DATE NOT NULL, 
  	"PerAssemblyQty" DECIMAL(8, 2) NOT NULL, 
  	"ProductAssemblyId" INTEGER, 
  	"StartDate" DATE NOT NULL, 
  	"UnitMeasureCode" VARCHAR(3) NOT NULL 
  );
  
  CREATE TABLE "Contact"
  (
  	"AdditionalContactInfo" BLOB SUB_TYPE 1, 
  	"ContactId" INTEGER NOT NULL, 
  	"EmailAddress" VARCHAR(50), 
  	"EmailPromotion" INTEGER NOT NULL, 
  	"FirstName" VARCHAR(50) NOT NULL, 
  	"LastName" VARCHAR(50) NOT NULL, 
  	"MiddleName" VARCHAR(50), 
  	"ModifiedDate" DATE NOT NULL, 
  	"PasswordHash" VARCHAR(128) NOT NULL, 
  	"PasswordSalt" VARCHAR(10) NOT NULL, 
  	"Phone" VARCHAR(25), 
  	"Suffix" VARCHAR(10), 
  	"Title" VARCHAR(8) 
  );
  
  CREATE TABLE "ContactCreditCard"
  (
  	"ContactId" INTEGER NOT NULL, 
  	"CreditCardId" INTEGER NOT NULL, 
  	"ModifiedDate" DATE NOT NULL 
  );
  
  CREATE TABLE "ContactType"
  (
  	"ContactTypeId" INTEGER NOT NULL, 
  	"ModifiedDate" DATE NOT NULL, 
  	"Name" VARCHAR(50) NOT NULL 
  );
  
  CREATE TABLE "CountryRegion"
  (
  	"CountryRegionCode" VARCHAR(3) NOT NULL, 
  	"ModifiedDate" DATE NOT NULL, 
  	"Name" VARCHAR(50) NOT NULL 
  );
  
  CREATE TABLE "CountryRegionCurrency"
  (
  	"CountryRegionCode" VARCHAR(3) NOT NULL, 
  	"CurrencyCode" VARCHAR(3) NOT NULL, 
  	"ModifiedDate" DATE NOT NULL 
  );
  
  CREATE TABLE "CreditCard"
  (
  	"CardNumber" VARCHAR(25) NOT NULL, 
  	"CardType" VARCHAR(50) NOT NULL, 
  	"CreditCardId" INTEGER NOT NULL, 
  	"ExpYear" SMALLINT NOT NULL, 
  	"ModifiedDate" DATE NOT NULL 
  );
  
  CREATE TABLE "Culture"
  (
  	"CultureId" VARCHAR(6) NOT NULL, 
  	"ModifiedDate" DATE NOT NULL, 
  	"Name" VARCHAR(50) NOT NULL 
  );
  
  CREATE TABLE "Currency"
  (
  	"CurrencyCode" VARCHAR(3) NOT NULL, 
  	"ModifiedDate" DATE NOT NULL, 
  	"Name" VARCHAR(50) NOT NULL 
  );
  
  CREATE TABLE "CurrencyRate"
  (
  	"AverageRate" DECIMAL(19, 4) NOT NULL, 
  	"CurrencyRateDate" DATE NOT NULL, 
  	"CurrencyRateId" INTEGER NOT NULL, 
  	"EndOfDayRate" DECIMAL(19, 4) NOT NULL, 
  	"FromCurrencyCode" VARCHAR(3) NOT NULL, 
  	"ModifiedDate" DATE NOT NULL, 
  	"ToCurrencyCode" VARCHAR(3) NOT NULL 
  );
  
  CREATE TABLE "Customer"
  (
  	"AccountNumber" VARCHAR(10) NOT NULL, 
  	"CustomerId" INTEGER NOT NULL, 
  	"CustomerType" VARCHAR(1) NOT NULL, 
  	"ModifiedDate" DATE NOT NULL, 
  	"TerritoryId" INTEGER 
  );
  
  CREATE TABLE "CustomerAddress"
  (
  	"AddressId" INTEGER NOT NULL, 
  	"AddressTypeId" INTEGER NOT NULL, 
  	"CustomerId" INTEGER NOT NULL, 
  	"ModifiedDate" DATE NOT NULL 
  );
  
  CREATE TABLE "Document"
  (
  	"ChangeNumber" INTEGER NOT NULL, 
  	"Document" BLOB SUB_TYPE 0, 
  	"DocumentId" INTEGER NOT NULL, 
  	"DocumentSummary" BLOB SUB_TYPE 1, 
  	"FileExtension" VARCHAR(8) NOT NULL, 
  	"FileName" VARCHAR(400) NOT NULL, 
  	"ModifiedDate" DATE NOT NULL, 
  	"Revision" VARCHAR(5) NOT NULL, 
  	"Title" VARCHAR(50) NOT NULL 
  );
  
  CREATE TABLE "EmployeeDepartmentHistory"
  (
  	"DepartmentId" SMALLINT NOT NULL, 
  	"EmployeeId" INTEGER NOT NULL, 
  	"EndDate" DATE, 
  	"ModifiedDate" DATE NOT NULL, 
  	"StartDate" DATE NOT NULL 
  );
  
  CREATE TABLE "EmployeePayHistory"
  (
  	"EmployeeId" INTEGER NOT NULL, 
  	"ModifiedDate" DATE NOT NULL, 
  	"Rate" DECIMAL(19, 4) NOT NULL, 
  	"RateChangeDate" DATE NOT NULL 
  );
  
  CREATE TABLE "Illustration"
  (
  	"Diagram" BLOB SUB_TYPE 1, 
  	"IllustrationId" INTEGER NOT NULL, 
  	"ModifiedDate" DATE NOT NULL 
  );
  
  CREATE TABLE "Individual"
  (
  	"ContactId" INTEGER NOT NULL, 
  	"CustomerId" INTEGER NOT NULL, 
  	"Demographics" BLOB SUB_TYPE 1, 
  	"ModifiedDate" DATE NOT NULL 
  );
  
  CREATE TABLE "JobCandidate"
  (
  	"EmployeeId" INTEGER, 
  	"JobCandidateId" INTEGER NOT NULL, 
  	"ModifiedDate" DATE NOT NULL, 
  	"Resume" BLOB SUB_TYPE 1 
  );
  
  CREATE TABLE "Location"
  (
  	"Availability" DECIMAL(8, 2) NOT NULL, 
  	"CostRate" DECIMAL(10, 4) NOT NULL, 
  	"LocationId" SMALLINT NOT NULL, 
  	"ModifiedDate" DATE NOT NULL, 
  	"Name" VARCHAR(50) NOT NULL 
  );
  
  CREATE TABLE "Product"
  (
  	"Class" VARCHAR(2), 
  	"Color" VARCHAR(15), 
  	"DaysToManufacture" INTEGER NOT NULL, 
  	"DiscontinuedDate" DATE, 
  	"ListPrice" DECIMAL(19, 4) NOT NULL, 
  	"ModifiedDate" DATE NOT NULL, 
  	"Name" VARCHAR(50) NOT NULL, 
  	"ProductId" INTEGER NOT NULL, 
  	"ProductLine" VARCHAR(2), 
  	"ProductModelId" INTEGER, 
  	"ProductNumber" VARCHAR(25) NOT NULL, 
  	"ProductSubcategoryId" INTEGER, 
  	"ReorderPoint" SMALLINT NOT NULL, 
  	"SafetyStockLevel" SMALLINT NOT NULL, 
  	"SellEndDate" DATE, 
  	"SellStartDate" DATE NOT NULL, 
  	"Size" VARCHAR(5), 
  	"SizeUnitMeasureCode" VARCHAR(3), 
  	"StandardCost" DECIMAL(19, 4) NOT NULL, 
  	"Style" VARCHAR(2), 
  	"Weight" DECIMAL(8, 2), 
  	"WeightUnitMeasureCode" VARCHAR(3) 
  );
  
  CREATE TABLE "ProductCategory"
  (
  	"ModifiedDate" DATE NOT NULL, 
  	"Name" VARCHAR(50) NOT NULL, 
  	"ProductCategoryId" INTEGER NOT NULL 
  );
  
  CREATE TABLE "ProductCostHistory"
  (
  	"EndDate" DATE, 
  	"ModifiedDate" DATE NOT NULL, 
  	"ProductId" INTEGER NOT NULL, 
  	"StandardCost" DECIMAL(19, 4) NOT NULL, 
  	"StartDate" DATE NOT NULL 
  );
  
  CREATE TABLE "ProductDescription"
  (
  	"Description" VARCHAR(400) NOT NULL, 
  	"ModifiedDate" DATE NOT NULL, 
  	"ProductDescriptionId" INTEGER NOT NULL 
  );
  
  CREATE TABLE "ProductDocument"
  (
  	"DocumentId" INTEGER NOT NULL, 
  	"ModifiedDate" DATE NOT NULL, 
  	"ProductId" INTEGER NOT NULL 
  );
  
  CREATE TABLE "ProductInventory"
  (
  	"LocationId" SMALLINT NOT NULL, 
  	"ModifiedDate" DATE NOT NULL, 
  	"ProductId" INTEGER NOT NULL, 
  	"Quantity" SMALLINT NOT NULL, 
  	"Shelf" VARCHAR(10) NOT NULL 
  );
  
  CREATE TABLE "ProductListPriceHistory"
  (
  	"EndDate" DATE, 
  	"ListPrice" DECIMAL(19, 4) NOT NULL, 
  	"ModifiedDate" DATE NOT NULL, 
  	"ProductId" INTEGER NOT NULL, 
  	"StartDate" DATE NOT NULL 
  );
  
  CREATE TABLE "ProductModel"
  (
  	"CatalogDescription" BLOB SUB_TYPE 1, 
  	"Instructions" BLOB SUB_TYPE 1, 
  	"ModifiedDate" DATE NOT NULL, 
  	"Name" VARCHAR(50) NOT NULL, 
  	"ProductModelId" INTEGER NOT NULL 
  );
  
  CREATE TABLE "ProductModelIllustration"
  (
  	"IllustrationId" INTEGER NOT NULL, 
  	"ModifiedDate" DATE NOT NULL, 
  	"ProductModelId" INTEGER NOT NULL 
  );
  
  CREATE TABLE "ProductModelProductDescriptionCulture"
  (
  	"CultureId" VARCHAR(6) NOT NULL, 
  	"ModifiedDate" DATE NOT NULL, 
  	"ProductDescriptionId" INTEGER NOT NULL, 
  	"ProductModelId" INTEGER NOT NULL 
  );
  
  CREATE TABLE "ProductPhoto"
  (
  	"LargePhoto" BLOB SUB_TYPE 0, 
  	"LargePhotoFileName" VARCHAR(50), 
  	"ModifiedDate" DATE NOT NULL, 
  	"ProductPhotoId" INTEGER NOT NULL, 
  	"ThumbNailPhoto" BLOB SUB_TYPE 0, 
  	"ThumbnailPhotoFileName" VARCHAR(50) 
  );
  
  CREATE TABLE "ProductProductPhoto"
  (
  	"ModifiedDate" DATE NOT NULL, 
  	"ProductId" INTEGER NOT NULL, 
  	"ProductPhotoId" INTEGER NOT NULL 
  );
  
  CREATE TABLE "ProductReview"
  (
  	"Comments" VARCHAR(3850), 
  	"EmailAddress" VARCHAR(50) NOT NULL, 
  	"ModifiedDate" DATE NOT NULL, 
  	"ProductId" INTEGER NOT NULL, 
  	"ProductReviewId" INTEGER NOT NULL, 
  	"Rating" INTEGER NOT NULL, 
  	"ReviewDate" DATE NOT NULL, 
  	"ReviewerName" VARCHAR(50) NOT NULL 
  );
  
  CREATE TABLE "ProductSubcategory"
  (
  	"ModifiedDate" DATE NOT NULL, 
  	"Name" VARCHAR(50) NOT NULL, 
  	"ProductCategoryId" INTEGER NOT NULL, 
  	"ProductSubcategoryId" INTEGER NOT NULL 
  );
  
  CREATE TABLE "ProductVendor"
  (
  	"AverageLeadTime" INTEGER NOT NULL, 
  	"LastReceiptCost" DECIMAL(19, 4), 
  	"LastReceiptDate" DATE, 
  	"MaxOrderQty" INTEGER NOT NULL, 
  	"MinOrderQty" INTEGER NOT NULL, 
  	"ModifiedDate" DATE NOT NULL, 
  	"OnOrderQty" INTEGER, 
  	"ProductId" INTEGER NOT NULL, 
  	"StandardPrice" DECIMAL(19, 4) NOT NULL, 
  	"UnitMeasureCode" VARCHAR(3) NOT NULL, 
  	"VendorId" INTEGER NOT NULL 
  );
  
  CREATE TABLE "PurchaseOrderDetail"
  (
  	"DueDate" DATE NOT NULL, 
  	"LineTotal" DECIMAL(19, 4) NOT NULL, 
  	"ModifiedDate" DATE NOT NULL, 
  	"OrderQty" SMALLINT NOT NULL, 
  	"ProductId" INTEGER NOT NULL, 
  	"PurchaseOrderDetailId" INTEGER NOT NULL, 
  	"PurchaseOrderId" INTEGER NOT NULL, 
  	"ReceivedQty" DECIMAL(8, 2) NOT NULL, 
  	"RejectedQty" DECIMAL(8, 2) NOT NULL, 
  	"StockedQty" DECIMAL(9, 2) NOT NULL, 
  	"UnitPrice" DECIMAL(19, 4) NOT NULL 
  );
  
  CREATE TABLE "PurchaseOrderHeader"
  (
  	"EmployeeId" INTEGER NOT NULL, 
  	"Freight" DECIMAL(19, 4) NOT NULL, 
  	"ModifiedDate" DATE NOT NULL, 
  	"OrderDate" DATE NOT NULL, 
  	"PurchaseOrderId" INTEGER NOT NULL, 
  	"ShipDate" DATE, 
  	"ShipMethodId" INTEGER NOT NULL, 
  	"SubTotal" DECIMAL(19, 4) NOT NULL, 
  	"TaxAmt" DECIMAL(19, 4) NOT NULL, 
  	"TotalDue" DECIMAL(19, 4) NOT NULL, 
  	"VendorId" INTEGER NOT NULL 
  );
  
  CREATE TABLE "SalesOrderDetail"
  (
  	"CarrierTrackingNumber" VARCHAR(25), 
  	"LineTotal" DECIMAL(38, 6) NOT NULL, 
  	"ModifiedDate" DATE NOT NULL, 
  	"OrderQty" SMALLINT NOT NULL, 
  	"ProductId" INTEGER NOT NULL, 
  	"SalesOrderDetailId" INTEGER NOT NULL, 
  	"SalesOrderId" INTEGER NOT NULL, 
  	"SpecialOfferId" INTEGER NOT NULL, 
  	"UnitPrice" DECIMAL(19, 4) NOT NULL, 
  	"UnitPriceDiscount" DECIMAL(19, 4) NOT NULL 
  );
  
  CREATE TABLE "SalesOrderHeader"
  (
  	"AccountNumber" VARCHAR(15), 
  	"BillToAddressId" INTEGER NOT NULL, 
  	"Comment" VARCHAR(128), 
  	"ContactId" INTEGER NOT NULL, 
  	"CreditCardApprovalCode" VARCHAR(15), 
  	"CreditCardId" INTEGER, 
  	"CurrencyRateId" INTEGER, 
  	"CustomerId" INTEGER NOT NULL, 
  	"DueDate" DATE NOT NULL, 
  	"Freight" DECIMAL(19, 4) NOT NULL, 
  	"ModifiedDate" DATE NOT NULL, 
  	"OrderDate" DATE NOT NULL, 
  	"PurchaseOrderNumber" VARCHAR(25), 
  	"SalesOrderId" INTEGER NOT NULL, 
  	"SalesOrderNumber" VARCHAR(25) NOT NULL, 
  	"SalesPersonId" INTEGER, 
  	"ShipDate" DATE, 
  	"ShipMethodId" INTEGER NOT NULL, 
  	"ShipToAddressId" INTEGER NOT NULL, 
  	"SubTotal" DECIMAL(19, 4) NOT NULL, 
  	"TaxAmt" DECIMAL(19, 4) NOT NULL, 
  	"TerritoryId" INTEGER, 
  	"TotalDue" DECIMAL(19, 4) NOT NULL 
  );
  
  CREATE TABLE "SalesOrderHeaderSalesReason"
  (
  	"ModifiedDate" DATE NOT NULL, 
  	"SalesOrderId" INTEGER NOT NULL, 
  	"SalesReasonId" INTEGER NOT NULL 
  );
  
  CREATE TABLE "SalesPerson"
  (
  	"Bonus" DECIMAL(19, 4) NOT NULL, 
  	"CommissionPct" DECIMAL(10, 4) NOT NULL, 
  	"ModifiedDate" DATE NOT NULL, 
  	"SalesLastYear" DECIMAL(19, 4) NOT NULL, 
  	"SalesPersonId" INTEGER NOT NULL, 
  	"SalesQuota" DECIMAL(19, 4), 
  	"SalesYtd" DECIMAL(19, 4) NOT NULL, 
  	"TerritoryId" INTEGER 
  );
  
  CREATE TABLE "SalesPersonQuotaHistory"
  (
  	"ModifiedDate" DATE NOT NULL, 
  	"QuotaDate" DATE NOT NULL, 
  	"SalesPersonId" INTEGER NOT NULL, 
  	"SalesQuota" DECIMAL(19, 4) NOT NULL 
  );
  
  CREATE TABLE "SalesReason"
  (
  	"ModifiedDate" DATE NOT NULL, 
  	"Name" VARCHAR(50) NOT NULL, 
  	"ReasonType" VARCHAR(50) NOT NULL, 
  	"SalesReasonId" INTEGER NOT NULL 
  );
  
  CREATE TABLE "SalesTaxRate"
  (
  	"ModifiedDate" DATE NOT NULL, 
  	"Name" VARCHAR(50) NOT NULL, 
  	"SalesTaxRateId" INTEGER NOT NULL, 
  	"StateProvinceId" INTEGER NOT NULL, 
  	"TaxRate" DECIMAL(10, 4) NOT NULL 
  );
  
  CREATE TABLE "SalesTerritory"
  (
  	"CostLastYear" DECIMAL(19, 4) NOT NULL, 
  	"CostYtd" DECIMAL(19, 4) NOT NULL, 
  	"CountryRegionCode" VARCHAR(3) NOT NULL, 
  	"Group" VARCHAR(50) NOT NULL, 
  	"ModifiedDate" DATE NOT NULL, 
  	"Name" VARCHAR(50) NOT NULL, 
  	"SalesLastYear" DECIMAL(19, 4) NOT NULL, 
  	"SalesYtd" DECIMAL(19, 4) NOT NULL, 
  	"TerritoryId" INTEGER NOT NULL 
  );
  
  CREATE TABLE "SalesTerritoryHistory"
  (
  	"EndDate" DATE, 
  	"ModifiedDate" DATE NOT NULL, 
  	"SalesPersonId" INTEGER NOT NULL, 
  	"StartDate" DATE NOT NULL, 
  	"TerritoryId" INTEGER NOT NULL 
  );
  
  CREATE TABLE "ScrapReason"
  (
  	"ModifiedDate" DATE NOT NULL, 
  	"Name" VARCHAR(50) NOT NULL, 
  	"ScrapReasonId" SMALLINT NOT NULL 
  );
  
  CREATE TABLE "Shift"
  (
  	"EndTime" DATE NOT NULL, 
  	"ModifiedDate" DATE NOT NULL, 
  	"Name" VARCHAR(50) NOT NULL, 
  	"StartTime" DATE NOT NULL 
  );
  
  CREATE TABLE "ShipMethod"
  (
  	"ModifiedDate" DATE NOT NULL, 
  	"Name" VARCHAR(50) NOT NULL, 
  	"ShipBase" DECIMAL(19, 4) NOT NULL, 
  	"ShipMethodId" INTEGER NOT NULL, 
  	"ShipRate" DECIMAL(19, 4) NOT NULL 
  );
  
  CREATE TABLE "ShoppingCartItem"
  (
  	"DateCreated" DATE NOT NULL, 
  	"ModifiedDate" DATE NOT NULL, 
  	"ProductId" INTEGER NOT NULL, 
  	"Quantity" INTEGER NOT NULL, 
  	"ShoppingCartId" VARCHAR(50) NOT NULL, 
  	"ShoppingCartItemId" INTEGER NOT NULL 
  );
  
  CREATE TABLE "SpecialOffer"
  (
  	"Category" VARCHAR(50) NOT NULL, 
  	"Description" VARCHAR(255) NOT NULL, 
  	"DiscountPct" DECIMAL(10, 4) NOT NULL, 
  	"EndDate" DATE NOT NULL, 
  	"MaxQty" INTEGER, 
  	"MinQty" INTEGER NOT NULL, 
  	"ModifiedDate" DATE NOT NULL, 
  	"SpecialOfferId" INTEGER NOT NULL, 
  	"StartDate" DATE NOT NULL, 
  	"Type" VARCHAR(50) NOT NULL 
  );
  
  CREATE TABLE "SpecialOfferProduct"
  (
  	"ModifiedDate" DATE NOT NULL, 
  	"ProductId" INTEGER NOT NULL, 
  	"SpecialOfferId" INTEGER NOT NULL 
  );
  
  CREATE TABLE "StateProvince"
  (
  	"CountryRegionCode" VARCHAR(3) NOT NULL, 
  	"ModifiedDate" DATE NOT NULL, 
  	"Name" VARCHAR(50) NOT NULL, 
  	"StateProvinceCode" VARCHAR(3) NOT NULL, 
  	"StateProvinceId" INTEGER NOT NULL, 
  	"TerritoryId" INTEGER NOT NULL 
  );
  
  CREATE TABLE "Store"
  (
  	"CustomerId" INTEGER NOT NULL, 
  	"Demographics" BLOB SUB_TYPE 1, 
  	"Name" VARCHAR(50) NOT NULL, 
  	"SalesPersonId" INTEGER 
  );
  
  CREATE TABLE "StoreContact"
  (
  	"ContactId" INTEGER NOT NULL, 
  	"ContactTypeId" INTEGER NOT NULL, 
  	"CustomerId" INTEGER NOT NULL, 
  	"ModifiedDate" DATE NOT NULL 
  );
  
  CREATE TABLE "TransactionHistory"
  (
  	"ActualCost" DECIMAL(19, 4) NOT NULL, 
  	"ModifiedDate" DATE NOT NULL, 
  	"ProductId" INTEGER NOT NULL, 
  	"Quantity" INTEGER NOT NULL, 
  	"ReferenceOrderId" INTEGER NOT NULL, 
  	"ReferenceOrderLineId" INTEGER NOT NULL, 
  	"TransactionDate" DATE NOT NULL, 
  	"TransactionId" INTEGER NOT NULL, 
  	"TransactionType" VARCHAR(1) NOT NULL 
  );
  
  CREATE TABLE "TransactionHistoryArchive"
  (
  	"ActualCost" DECIMAL(19, 4) NOT NULL, 
  	"ModifiedDate" DATE NOT NULL, 
  	"ProductId" INTEGER NOT NULL, 
  	"Quantity" INTEGER NOT NULL, 
  	"ReferenceOrderId" INTEGER NOT NULL, 
  	"ReferenceOrderLineId" INTEGER NOT NULL, 
  	"TransactionDate" DATE NOT NULL, 
  	"TransactionId" INTEGER NOT NULL, 
  	"TransactionType" VARCHAR(1) NOT NULL 
  );
  
  CREATE TABLE "UnitMeasure"
  (
  	"ModifiedDate" DATE NOT NULL, 
  	"Name" VARCHAR(50) NOT NULL, 
  	"UnitMeasureCode" VARCHAR(3) NOT NULL 
  );
  
  CREATE TABLE "Vendor"
  (
  	"AccountNumber" VARCHAR(15) NOT NULL, 
  	"ModifiedDate" DATE NOT NULL, 
  	"Name" VARCHAR(50) NOT NULL, 
  	"PurchasingWebServiceUrl" VARCHAR(1024), 
  	"VendorId" INTEGER NOT NULL 
  );
  
  CREATE TABLE "VendorAddress"
  (
  	"AddressId" INTEGER NOT NULL, 
  	"AddressTypeId" INTEGER NOT NULL, 
  	"ModifiedDate" DATE NOT NULL, 
  	"VendorId" INTEGER NOT NULL 
  );
  
  CREATE TABLE "VendorContact"
  (
  	"ContactId" INTEGER NOT NULL, 
  	"ContactTypeId" INTEGER NOT NULL, 
  	"ModifiedDate" DATE NOT NULL, 
  	"VendorId" INTEGER NOT NULL 
  );
  
  CREATE TABLE "WorkOrder"
  (
  	"DueDate" DATE NOT NULL, 
  	"EndDate" DATE, 
  	"ModifiedDate" DATE NOT NULL, 
  	"OrderQty" INTEGER NOT NULL, 
  	"ProductId" INTEGER NOT NULL, 
  	"ScrappedQty" SMALLINT NOT NULL, 
  	"ScrapReasonId" SMALLINT, 
  	"StartDate" DATE NOT NULL, 
  	"StockedQty" INTEGER NOT NULL, 
  	"WorkOrderId" INTEGER NOT NULL 
  );
  
  CREATE TABLE "WorkOrderRouting"
  (
  	"ActualCost" DECIMAL(19, 4), 
  	"ActualEndDate" DATE, 
  	"ActualResourceHrs" DECIMAL(9, 4), 
  	"ActualStartDate" DATE, 
  	"LocationId" SMALLINT NOT NULL, 
  	"ModifiedDate" DATE NOT NULL, 
  	"OperationSequence" SMALLINT NOT NULL, 
  	"PlannedCost" DECIMAL(19, 4) NOT NULL, 
  	"ProductId" INTEGER NOT NULL, 
  	"ScheduledEndDate" DATE NOT NULL, 
  	"ScheduledStartDate" DATE NOT NULL, 
  	"WorkOrderId" INTEGER NOT NULL 
  );
  
  CREATE GENERATOR "SEQ_Address";
  
  CREATE GENERATOR "SEQ_AddressType";
  
  CREATE GENERATOR "SEQ_BillOfMaterial";
  
  CREATE GENERATOR "SEQ_Contact";
  
  CREATE GENERATOR "SEQ_ContactType";
  
  CREATE GENERATOR "SEQ_CreditCard";
  
  CREATE GENERATOR "SEQ_CurrencyRate";
  
  CREATE GENERATOR "SEQ_Customer";
  
  CREATE GENERATOR "SEQ_Document";
  
  CREATE GENERATOR "SEQ_Illustration";
  
  CREATE GENERATOR "SEQ_JobCandidate";
  
  CREATE GENERATOR "SEQ_Product";
  
  CREATE GENERATOR "SEQ_ProductCategory";
  
  CREATE GENERATOR "SEQ_ProductDescription";
  
  CREATE GENERATOR "SEQ_ProductModel";
  
  CREATE GENERATOR "SEQ_ProductPhoto";
  
  CREATE GENERATOR "SEQ_ProductReview";
  
  CREATE GENERATOR "SEQ_ProductSubcategory";
  
  CREATE GENERATOR "SEQ_PurchaseOrderHeader";
  
  CREATE GENERATOR "SEQ_SalesOrderHeader";
  
  CREATE GENERATOR "SEQ_SalesReason";
  
  CREATE GENERATOR "SEQ_SalesTaxRate";
  
  CREATE GENERATOR "SEQ_SalesTerritory";
  
  CREATE GENERATOR "SEQ_ShipMethod";
  
  CREATE GENERATOR "SEQ_ShoppingCartItem";
  
  CREATE GENERATOR "SEQ_SpecialOffer";
  
  CREATE GENERATOR "SEQ_StateProvince";
  
  CREATE GENERATOR "SEQ_TransactionHistory";
  
  CREATE GENERATOR "SEQ_TransactionHistoryArchive";
  
  CREATE GENERATOR "SEQ_Vendor";
  
  CREATE GENERATOR "SEQ_WorkOrder";
  
  -- ###############################################################################################################
  -- ALTER statements for table fields and ADD statements for new primary key constraints
  -- ###############################################################################################################
  
  -- ###############################################################################################################
  -- ADD statements for new foreign key constraints and unique constraints
  -- ###############################################################################################################
  
  