### Database Schema:
CREATE TABLE ProductProductPhoto (
	ProductID	INTEGER	NOT NULL	PRIMARY KEY,
	ProductPhotoID	INTEGER	NOT NULL	PRIMARY KEY,
	Primary	INTEGER	NOT NULL	DEFAULT 0,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP,
	foreign key (ProductID) references Product (ProductID),
	foreign key (ProductPhotoID) references ProductPhoto (ProductPhotoID)
);

CREATE TABLE BillOfMaterials (
	BillOfMaterialsID	INTEGER	NULL	PRIMARY KEY,
	ProductAssemblyID	INTEGER	NULL,
	ComponentID	INTEGER	NOT NULL,
	StartDate	DATETIME	NOT NULL	DEFAULT current_timestamp,
	EndDate	DATETIME	NULL,
	UnitMeasureCode	TEXT	NOT NULL,
	BOMLevel	INTEGER	NOT NULL,
	PerAssemblyQty	REAL	NOT NULL	DEFAULT 1.00,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT current_timestamp,
	foreign key (UnitMeasureCode) references UnitMeasure (UnitMeasureCode),
	foreign key (ComponentID) references Product (ProductID),
	foreign key (ProductAssemblyID) references Product (ProductID)
);

CREATE TABLE Address (
	AddressID	INTEGER	NULL	PRIMARY KEY,
	AddressLine1	TEXT	NOT NULL,
	AddressLine2	TEXT	NULL,
	City	TEXT	NOT NULL,
	StateProvinceID	INTEGER	NOT NULL,
	PostalCode	TEXT	NOT NULL,
	SpatialLocation	TEXT	NULL,
	rowguid	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT current_timestamp,
	foreign key (StateProvinceID) references StateProvince (StateProvinceID)
);

CREATE TABLE SpecialOfferProduct (
	SpecialOfferID	INTEGER	NOT NULL	PRIMARY KEY,
	ProductID	INTEGER	NOT NULL	PRIMARY KEY,
	rowguid	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP,
	foreign key (ProductID) references Product (ProductID),
	foreign key (SpecialOfferID) references SpecialOffer (SpecialOfferID)
);

CREATE TABLE ProductCategory (
	ProductCategoryID	INTEGER	NULL	PRIMARY KEY,
	Name	TEXT	NOT NULL,
	rowguid	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE SalesTerritoryHistory (
	BusinessEntityID	INTEGER	NOT NULL	PRIMARY KEY,
	TerritoryID	INTEGER	NOT NULL	PRIMARY KEY,
	StartDate	DATETIME	NOT NULL	PRIMARY KEY,
	EndDate	DATETIME	NULL,
	rowguid	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP,
	foreign key (BusinessEntityID) references SalesPerson (BusinessEntityID),
	foreign key (TerritoryID) references SalesTerritory (TerritoryID)
);

CREATE TABLE PurchaseOrderDetail (
	PurchaseOrderID	INTEGER	NOT NULL,
	PurchaseOrderDetailID	INTEGER	NULL	PRIMARY KEY,
	DueDate	DATETIME	NOT NULL,
	OrderQty	INTEGER	NOT NULL,
	ProductID	INTEGER	NOT NULL,
	UnitPrice	REAL	NOT NULL,
	LineTotal	REAL	NOT NULL,
	ReceivedQty	REAL	NOT NULL,
	RejectedQty	REAL	NOT NULL,
	StockedQty	REAL	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP,
	foreign key (ProductID) references Product (ProductID),
	foreign key (PurchaseOrderID) references PurchaseOrderHeader (PurchaseOrderID)
);

CREATE TABLE Product (
	ProductID	INTEGER	NULL	PRIMARY KEY,
	Name	TEXT	NOT NULL,
	ProductNumber	TEXT	NOT NULL,
	MakeFlag	INTEGER	NOT NULL	DEFAULT 1,
	FinishedGoodsFlag	INTEGER	NOT NULL	DEFAULT 1,
	Color	TEXT	NULL,
	SafetyStockLevel	INTEGER	NOT NULL,
	ReorderPoint	INTEGER	NOT NULL,
	StandardCost	REAL	NOT NULL,
	ListPrice	REAL	NOT NULL,
	Size	TEXT	NULL,
	SizeUnitMeasureCode	TEXT	NULL,
	WeightUnitMeasureCode	TEXT	NULL,
	Weight	REAL	NULL,
	DaysToManufacture	INTEGER	NOT NULL,
	ProductLine	TEXT	NULL,
	Class	TEXT	NULL,
	Style	TEXT	NULL,
	ProductSubcategoryID	INTEGER	NULL,
	ProductModelID	INTEGER	NULL,
	SellStartDate	DATETIME	NOT NULL,
	SellEndDate	DATETIME	NULL,
	DiscontinuedDate	DATETIME	NULL,
	rowguid	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT current_timestamp,
	foreign key (ProductSubcategoryID) references ProductSubcategory (ProductSubcategoryID),
	foreign key (WeightUnitMeasureCode) references UnitMeasure (UnitMeasureCode),
	foreign key (ProductModelID) references ProductModel (ProductModelID),
	foreign key (SizeUnitMeasureCode) references UnitMeasure (UnitMeasureCode)
);

CREATE TABLE SalesOrderHeaderSalesReason (
	SalesOrderID	INTEGER	NOT NULL	PRIMARY KEY,
	SalesReasonID	INTEGER	NOT NULL	PRIMARY KEY,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP,
	foreign key (SalesOrderID) references SalesOrderHeader (SalesOrderID),
	foreign key (SalesReasonID) references SalesReason (SalesReasonID)
);

CREATE TABLE ProductCostHistory (
	ProductID	INTEGER	NOT NULL	PRIMARY KEY,
	StartDate	DATE	NOT NULL	PRIMARY KEY,
	EndDate	DATE	NULL,
	StandardCost	REAL	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP,
	foreign key (ProductID) references Product (ProductID)
);

CREATE TABLE ProductVendor (
	ProductID	INTEGER	NOT NULL	PRIMARY KEY,
	BusinessEntityID	INTEGER	NOT NULL	PRIMARY KEY,
	AverageLeadTime	INTEGER	NOT NULL,
	StandardPrice	REAL	NOT NULL,
	LastReceiptCost	REAL	NULL,
	LastReceiptDate	DATETIME	NULL,
	MinOrderQty	INTEGER	NOT NULL,
	MaxOrderQty	INTEGER	NOT NULL,
	OnOrderQty	INTEGER	NULL,
	UnitMeasureCode	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP,
	foreign key (ProductID) references Product (ProductID),
	foreign key (UnitMeasureCode) references UnitMeasure (UnitMeasureCode),
	foreign key (BusinessEntityID) references Vendor (BusinessEntityID)
);

CREATE TABLE ShoppingCartItem (
	ShoppingCartItemID	INTEGER	NULL	PRIMARY KEY,
	ShoppingCartID	TEXT	NOT NULL,
	Quantity	INTEGER	NOT NULL	DEFAULT 1,
	ProductID	INTEGER	NOT NULL,
	DateCreated	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP,
	foreign key (ProductID) references Product (ProductID)
);

CREATE TABLE Currency (
	CurrencyCode	TEXT	NOT NULL	PRIMARY KEY,
	Name	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT current_timestamp
);

CREATE TABLE SalesOrderHeader (
	SalesOrderID	INTEGER	NULL	PRIMARY KEY,
	RevisionNumber	INTEGER	NOT NULL	DEFAULT 0,
	OrderDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP,
	DueDate	DATETIME	NOT NULL,
	ShipDate	DATETIME	NULL,
	Status	INTEGER	NOT NULL	DEFAULT 1,
	OnlineOrderFlag	INTEGER	NOT NULL	DEFAULT 1,
	SalesOrderNumber	TEXT	NOT NULL,
	PurchaseOrderNumber	TEXT	NULL,
	AccountNumber	TEXT	NULL,
	CustomerID	INTEGER	NOT NULL,
	SalesPersonID	INTEGER	NULL,
	TerritoryID	INTEGER	NULL,
	BillToAddressID	INTEGER	NOT NULL,
	ShipToAddressID	INTEGER	NOT NULL,
	ShipMethodID	INTEGER	NOT NULL,
	CreditCardID	INTEGER	NULL,
	CreditCardApprovalCode	TEXT	NULL,
	CurrencyRateID	INTEGER	NULL,
	SubTotal	REAL	NOT NULL	DEFAULT 0.0000,
	TaxAmt	REAL	NOT NULL	DEFAULT 0.0000,
	Freight	REAL	NOT NULL	DEFAULT 0.0000,
	TotalDue	REAL	NOT NULL,
	Comment	TEXT	NULL,
	rowguid	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP,
	foreign key (SalesPersonID) references SalesPerson (BusinessEntityID),
	foreign key (TerritoryID) references SalesTerritory (TerritoryID),
	foreign key (CurrencyRateID) references CurrencyRate (CurrencyRateID),
	foreign key (CreditCardID) references CreditCard (CreditCardID),
	foreign key (BillToAddressID) references Address (AddressID),
	foreign key (CustomerID) references Customer (CustomerID),
	foreign key (ShipMethodID) references Address (AddressID),
	foreign key (ShipToAddressID) references Address (AddressID)
);

CREATE TABLE SalesReason (
	SalesReasonID	INTEGER	NULL	PRIMARY KEY,
	Name	TEXT	NOT NULL,
	ReasonType	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE CountryRegionCurrency (
	CountryRegionCode	TEXT	NOT NULL	PRIMARY KEY,
	CurrencyCode	TEXT	NOT NULL	PRIMARY KEY,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT current_timestamp,
	foreign key (CurrencyCode) references Currency (CurrencyCode),
	foreign key (CountryRegionCode) references CountryRegion (CountryRegionCode)
);

CREATE TABLE Department (
	DepartmentID	INTEGER	NULL	PRIMARY KEY,
	Name	TEXT	NOT NULL,
	GroupName	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT current_timestamp
);

CREATE TABLE EmailAddress (
	BusinessEntityID	INTEGER	NOT NULL	PRIMARY KEY,
	EmailAddressID	INTEGER	NULL	PRIMARY KEY,
	EmailAddress	TEXT	NULL,
	rowguid	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT current_timestamp,
	foreign key (BusinessEntityID) references Person (BusinessEntityID)
);

CREATE TABLE ProductDocument (
	ProductID	INTEGER	NOT NULL	PRIMARY KEY,
	DocumentNode	TEXT	NOT NULL	PRIMARY KEY,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP,
	foreign key (ProductID) references Product (ProductID),
	foreign key (DocumentNode) references Document (DocumentNode)
);

CREATE TABLE EmployeePayHistory (
	BusinessEntityID	INTEGER	NOT NULL	PRIMARY KEY,
	RateChangeDate	DATETIME	NOT NULL	PRIMARY KEY,
	Rate	REAL	NOT NULL,
	PayFrequency	INTEGER	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT current_timestamp,
	foreign key (BusinessEntityID) references Employee (BusinessEntityID)
);

CREATE TABLE PhoneNumberType (
	PhoneNumberTypeID	INTEGER	NULL	PRIMARY KEY,
	Name	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT current_timestamp
);

CREATE TABLE ProductInventory (
	ProductID	INTEGER	NOT NULL	PRIMARY KEY,
	LocationID	INTEGER	NOT NULL	PRIMARY KEY,
	Shelf	TEXT	NOT NULL,
	Bin	INTEGER	NOT NULL,
	Quantity	INTEGER	NOT NULL	DEFAULT 0,
	rowguid	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP,
	foreign key (LocationID) references Location (LocationID),
	foreign key (ProductID) references Product (ProductID)
);

CREATE TABLE ProductListPriceHistory (
	ProductID	INTEGER	NOT NULL	PRIMARY KEY,
	StartDate	DATE	NOT NULL	PRIMARY KEY,
	EndDate	DATE	NULL,
	ListPrice	REAL	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP,
	foreign key (ProductID) references Product (ProductID)
);

CREATE TABLE Vendor (
	BusinessEntityID	INTEGER	NOT NULL	PRIMARY KEY,
	AccountNumber	TEXT	NOT NULL,
	Name	TEXT	NOT NULL,
	CreditRating	INTEGER	NOT NULL,
	PreferredVendorStatus	INTEGER	NOT NULL	DEFAULT 1,
	ActiveFlag	INTEGER	NOT NULL	DEFAULT 1,
	PurchasingWebServiceURL	TEXT	NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP,
	foreign key (BusinessEntityID) references BusinessEntity (BusinessEntityID)
);

CREATE TABLE WorkOrder (
	WorkOrderID	INTEGER	NULL	PRIMARY KEY,
	ProductID	INTEGER	NOT NULL,
	OrderQty	INTEGER	NOT NULL,
	StockedQty	INTEGER	NOT NULL,
	ScrappedQty	INTEGER	NOT NULL,
	StartDate	DATETIME	NOT NULL,
	EndDate	DATETIME	NULL,
	DueDate	DATETIME	NOT NULL,
	ScrapReasonID	INTEGER	NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP,
	foreign key (ScrapReasonID) references ScrapReason (ScrapReasonID),
	foreign key (ProductID) references Product (ProductID)
);

CREATE TABLE JobCandidate (
	JobCandidateID	INTEGER	NULL	PRIMARY KEY,
	BusinessEntityID	INTEGER	NULL,
	Resume	TEXT	NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT current_timestamp,
	foreign key (BusinessEntityID) references Employee (BusinessEntityID)
);

CREATE TABLE TransactionHistory (
	TransactionID	INTEGER	NULL	PRIMARY KEY,
	ProductID	INTEGER	NOT NULL,
	ReferenceOrderID	INTEGER	NOT NULL,
	ReferenceOrderLineID	INTEGER	NOT NULL	DEFAULT 0,
	TransactionDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP,
	TransactionType	TEXT	NOT NULL,
	Quantity	INTEGER	NOT NULL,
	ActualCost	REAL	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP,
	foreign key (ProductID) references Product (ProductID)
);

CREATE TABLE SalesPerson (
	BusinessEntityID	INTEGER	NOT NULL	PRIMARY KEY,
	TerritoryID	INTEGER	NULL,
	SalesQuota	REAL	NULL,
	Bonus	REAL	NOT NULL	DEFAULT 0.0000,
	CommissionPct	REAL	NOT NULL	DEFAULT 0.0000,
	SalesYTD	REAL	NOT NULL	DEFAULT 0.0000,
	SalesLastYear	REAL	NOT NULL	DEFAULT 0.0000,
	rowguid	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP,
	foreign key (TerritoryID) references SalesTerritory (TerritoryID),
	foreign key (BusinessEntityID) references Employee (BusinessEntityID)
);

CREATE TABLE AddressType (
	AddressTypeID	INTEGER	NULL	PRIMARY KEY,
	Name	TEXT	NOT NULL,
	rowguid	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT current_timestamp
);

CREATE TABLE SalesOrderDetail (
	SalesOrderID	INTEGER	NOT NULL,
	SalesOrderDetailID	INTEGER	NULL	PRIMARY KEY,
	CarrierTrackingNumber	TEXT	NULL,
	OrderQty	INTEGER	NOT NULL,
	ProductID	INTEGER	NOT NULL,
	SpecialOfferID	INTEGER	NOT NULL,
	UnitPrice	REAL	NOT NULL,
	UnitPriceDiscount	REAL	NOT NULL	DEFAULT 0.0000,
	LineTotal	REAL	NOT NULL,
	rowguid	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP,
	foreign key (ProductID) references SpecialOfferProduct (ProductID),
	foreign key (SalesOrderID) references SalesOrderHeader (SalesOrderID),
	foreign key (SpecialOfferID) references SpecialOfferProduct (SpecialOfferID)
);

CREATE TABLE ProductDescription (
	ProductDescriptionID	INTEGER	NULL	PRIMARY KEY,
	Description	TEXT	NOT NULL,
	rowguid	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE ScrapReason (
	ScrapReasonID	INTEGER	NULL	PRIMARY KEY,
	Name	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE TransactionHistoryArchive (
	TransactionID	INTEGER	NOT NULL	PRIMARY KEY,
	ProductID	INTEGER	NOT NULL,
	ReferenceOrderID	INTEGER	NOT NULL,
	ReferenceOrderLineID	INTEGER	NOT NULL	DEFAULT 0,
	TransactionDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP,
	TransactionType	TEXT	NOT NULL,
	Quantity	INTEGER	NOT NULL,
	ActualCost	REAL	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE ProductReview (
	ProductReviewID	INTEGER	NULL	PRIMARY KEY,
	ProductID	INTEGER	NOT NULL,
	ReviewerName	TEXT	NOT NULL,
	ReviewDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP,
	EmailAddress	TEXT	NOT NULL,
	Rating	INTEGER	NOT NULL,
	Comments	TEXT	NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP,
	foreign key (ProductID) references Product (ProductID)
);

CREATE TABLE Store (
	BusinessEntityID	INTEGER	NOT NULL	PRIMARY KEY,
	Name	TEXT	NOT NULL,
	SalesPersonID	INTEGER	NULL,
	Demographics	TEXT	NULL,
	rowguid	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP,
	foreign key (BusinessEntityID) references BusinessEntity (BusinessEntityID),
	foreign key (SalesPersonID) references SalesPerson (BusinessEntityID)
);

CREATE TABLE ProductModelProductDescriptionCulture (
	ProductModelID	INTEGER	NOT NULL	PRIMARY KEY,
	ProductDescriptionID	INTEGER	NOT NULL	PRIMARY KEY,
	CultureID	TEXT	NOT NULL	PRIMARY KEY,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP,
	foreign key (CultureID) references Culture (CultureID),
	foreign key (ProductModelID) references ProductModel (ProductModelID),
	foreign key (ProductDescriptionID) references ProductDescription (ProductDescriptionID)
);

CREATE TABLE SalesPersonQuotaHistory (
	BusinessEntityID	INTEGER	NOT NULL	PRIMARY KEY,
	QuotaDate	DATETIME	NOT NULL	PRIMARY KEY,
	SalesQuota	REAL	NOT NULL,
	rowguid	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP,
	foreign key (BusinessEntityID) references SalesPerson (BusinessEntityID)
);

CREATE TABLE Customer (
	CustomerID	INTEGER	NULL	PRIMARY KEY,
	PersonID	INTEGER	NULL,
	StoreID	INTEGER	NULL,
	TerritoryID	INTEGER	NULL,
	AccountNumber	TEXT	NOT NULL,
	rowguid	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT current_timestamp,
	foreign key (StoreID) references Store (BusinessEntityID),
	foreign key (TerritoryID) references SalesTerritory (TerritoryID),
	foreign key (PersonID) references Person (BusinessEntityID)
);

CREATE TABLE ShipMethod (
	ShipMethodID	INTEGER	NULL	PRIMARY KEY,
	Name	TEXT	NOT NULL,
	ShipBase	REAL	NOT NULL	DEFAULT 0.0000,
	ShipRate	REAL	NOT NULL	DEFAULT 0.0000,
	rowguid	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE Person (
	BusinessEntityID	INTEGER	NOT NULL	PRIMARY KEY,
	PersonType	TEXT	NOT NULL,
	NameStyle	INTEGER	NOT NULL	DEFAULT 0,
	Title	TEXT	NULL,
	FirstName	TEXT	NOT NULL,
	MiddleName	TEXT	NULL,
	LastName	TEXT	NOT NULL,
	Suffix	TEXT	NULL,
	EmailPromotion	INTEGER	NOT NULL	DEFAULT 0,
	AdditionalContactInfo	TEXT	NULL,
	Demographics	TEXT	NULL,
	rowguid	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT current_timestamp,
	foreign key (BusinessEntityID) references BusinessEntity (BusinessEntityID)
);

CREATE TABLE ProductSubcategory (
	ProductSubcategoryID	INTEGER	NULL	PRIMARY KEY,
	ProductCategoryID	INTEGER	NOT NULL,
	Name	TEXT	NOT NULL,
	rowguid	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP,
	foreign key (ProductCategoryID) references ProductCategory (ProductCategoryID)
);

CREATE TABLE SalesTaxRate (
	SalesTaxRateID	INTEGER	NULL	PRIMARY KEY,
	StateProvinceID	INTEGER	NOT NULL,
	TaxType	INTEGER	NOT NULL,
	TaxRate	REAL	NOT NULL	DEFAULT 0.0000,
	Name	TEXT	NOT NULL,
	rowguid	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP,
	foreign key (StateProvinceID) references StateProvince (StateProvinceID)
);

CREATE TABLE CountryRegion (
	CountryRegionCode	TEXT	NOT NULL	PRIMARY KEY,
	Name	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT current_timestamp
);

CREATE TABLE Shift (
	ShiftID	INTEGER	NULL	PRIMARY KEY,
	Name	TEXT	NOT NULL,
	StartTime	TEXT	NOT NULL,
	EndTime	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE BusinessEntityContact (
	BusinessEntityID	INTEGER	NOT NULL	PRIMARY KEY,
	PersonID	INTEGER	NOT NULL	PRIMARY KEY,
	ContactTypeID	INTEGER	NOT NULL	PRIMARY KEY,
	rowguid	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT current_timestamp,
	foreign key (BusinessEntityID) references BusinessEntity (BusinessEntityID),
	foreign key (ContactTypeID) references ContactType (ContactTypeID),
	foreign key (PersonID) references Person (BusinessEntityID)
);

CREATE TABLE BusinessEntityAddress (
	BusinessEntityID	INTEGER	NOT NULL	PRIMARY KEY,
	AddressID	INTEGER	NOT NULL	PRIMARY KEY,
	AddressTypeID	INTEGER	NOT NULL	PRIMARY KEY,
	rowguid	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT current_timestamp,
	foreign key (BusinessEntityID) references BusinessEntity (BusinessEntityID),
	foreign key (AddressID) references Address (AddressID),
	foreign key (AddressTypeID) references AddressType (AddressTypeID)
);

CREATE TABLE EmployeeDepartmentHistory (
	BusinessEntityID	INTEGER	NOT NULL	PRIMARY KEY,
	DepartmentID	INTEGER	NOT NULL	PRIMARY KEY,
	ShiftID	INTEGER	NOT NULL	PRIMARY KEY,
	StartDate	DATE	NOT NULL	PRIMARY KEY,
	EndDate	DATE	NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT current_timestamp,
	foreign key (BusinessEntityID) references Employee (BusinessEntityID),
	foreign key (ShiftID) references Shift (ShiftID),
	foreign key (DepartmentID) references Department (DepartmentID)
);

CREATE TABLE StateProvince (
	StateProvinceID	INTEGER	NULL	PRIMARY KEY,
	StateProvinceCode	TEXT	NOT NULL,
	CountryRegionCode	TEXT	NOT NULL,
	IsOnlyStateProvinceFlag	INTEGER	NOT NULL	DEFAULT 1,
	Name	TEXT	NOT NULL,
	TerritoryID	INTEGER	NOT NULL,
	rowguid	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP,
	foreign key (CountryRegionCode) references CountryRegion (CountryRegionCode),
	foreign key (TerritoryID) references SalesTerritory (TerritoryID)
);

CREATE TABLE ProductModel (
	ProductModelID	INTEGER	NULL	PRIMARY KEY,
	Name	TEXT	NOT NULL,
	CatalogDescription	TEXT	NULL,
	Instructions	TEXT	NULL,
	rowguid	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE Culture (
	CultureID	TEXT	NOT NULL	PRIMARY KEY,
	Name	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT current_timestamp
);

CREATE TABLE SalesTerritory (
	TerritoryID	INTEGER	NULL	PRIMARY KEY,
	Name	TEXT	NOT NULL,
	CountryRegionCode	TEXT	NOT NULL,
	Group	TEXT	NOT NULL,
	SalesYTD	REAL	NOT NULL	DEFAULT 0.0000,
	SalesLastYear	REAL	NOT NULL	DEFAULT 0.0000,
	CostYTD	REAL	NOT NULL	DEFAULT 0.0000,
	CostLastYear	REAL	NOT NULL	DEFAULT 0.0000,
	rowguid	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP,
	foreign key (CountryRegionCode) references CountryRegion (CountryRegionCode)
);

CREATE TABLE Location (
	LocationID	INTEGER	NULL	PRIMARY KEY,
	Name	TEXT	NOT NULL,
	CostRate	REAL	NOT NULL	DEFAULT 0.0000,
	Availability	REAL	NOT NULL	DEFAULT 0.00,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT current_timestamp
);

CREATE TABLE Password (
	BusinessEntityID	INTEGER	NOT NULL	PRIMARY KEY,
	PasswordHash	TEXT	NOT NULL,
	PasswordSalt	TEXT	NOT NULL,
	rowguid	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT current_timestamp,
	foreign key (BusinessEntityID) references Person (BusinessEntityID)
);

CREATE TABLE ProductPhoto (
	ProductPhotoID	INTEGER	NULL	PRIMARY KEY,
	ThumbNailPhoto	BLOB	NULL,
	ThumbnailPhotoFileName	TEXT	NULL,
	LargePhoto	BLOB	NULL,
	LargePhotoFileName	TEXT	NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE BusinessEntity (
	BusinessEntityID	INTEGER	NULL	PRIMARY KEY,
	rowguid	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT current_timestamp
);

CREATE TABLE UnitMeasure (
	UnitMeasureCode	TEXT	NOT NULL	PRIMARY KEY,
	Name	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE ContactType (
	ContactTypeID	INTEGER	NULL	PRIMARY KEY,
	Name	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT current_timestamp
);

CREATE TABLE WorkOrderRouting (
	WorkOrderID	INTEGER	NOT NULL	PRIMARY KEY,
	ProductID	INTEGER	NOT NULL	PRIMARY KEY,
	OperationSequence	INTEGER	NOT NULL	PRIMARY KEY,
	LocationID	INTEGER	NOT NULL,
	ScheduledStartDate	DATETIME	NOT NULL,
	ScheduledEndDate	DATETIME	NOT NULL,
	ActualStartDate	DATETIME	NULL,
	ActualEndDate	DATETIME	NULL,
	ActualResourceHrs	REAL	NULL,
	PlannedCost	REAL	NOT NULL,
	ActualCost	REAL	NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP,
	foreign key (WorkOrderID) references WorkOrder (WorkOrderID),
	foreign key (LocationID) references Location (LocationID)
);

CREATE TABLE CreditCard (
	CreditCardID	INTEGER	NULL	PRIMARY KEY,
	CardType	TEXT	NOT NULL,
	CardNumber	TEXT	NOT NULL,
	ExpMonth	INTEGER	NOT NULL,
	ExpYear	INTEGER	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT current_timestamp
);

CREATE TABLE PersonCreditCard (
	BusinessEntityID	INTEGER	NOT NULL	PRIMARY KEY,
	CreditCardID	INTEGER	NOT NULL	PRIMARY KEY,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT current_timestamp,
	foreign key (BusinessEntityID) references Person (BusinessEntityID),
	foreign key (CreditCardID) references CreditCard (CreditCardID)
);

CREATE TABLE Document (
	DocumentNode	TEXT	NOT NULL	PRIMARY KEY,
	DocumentLevel	INTEGER	NULL,
	Title	TEXT	NOT NULL,
	Owner	INTEGER	NOT NULL,
	FolderFlag	INTEGER	NOT NULL	DEFAULT 0,
	FileName	TEXT	NOT NULL,
	FileExtension	TEXT	NOT NULL,
	Revision	TEXT	NOT NULL,
	ChangeNumber	INTEGER	NOT NULL	DEFAULT 0,
	Status	INTEGER	NOT NULL,
	DocumentSummary	TEXT	NULL,
	Document	BLOB	NULL,
	rowguid	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT current_timestamp,
	foreign key (Owner) references Employee (BusinessEntityID)
);

CREATE TABLE SpecialOffer (
	SpecialOfferID	INTEGER	NULL	PRIMARY KEY,
	Description	TEXT	NOT NULL,
	DiscountPct	REAL	NOT NULL	DEFAULT 0.0000,
	Type	TEXT	NOT NULL,
	Category	TEXT	NOT NULL,
	StartDate	DATETIME	NOT NULL,
	EndDate	DATETIME	NOT NULL,
	MinQty	INTEGER	NOT NULL	DEFAULT 0,
	MaxQty	INTEGER	NULL,
	rowguid	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE Employee (
	BusinessEntityID	INTEGER	NOT NULL	PRIMARY KEY,
	NationalIDNumber	TEXT	NOT NULL,
	LoginID	TEXT	NOT NULL,
	OrganizationNode	TEXT	NULL,
	OrganizationLevel	INTEGER	NULL,
	JobTitle	TEXT	NOT NULL,
	BirthDate	DATE	NOT NULL,
	MaritalStatus	TEXT	NOT NULL,
	Gender	TEXT	NOT NULL,
	HireDate	DATE	NOT NULL,
	SalariedFlag	INTEGER	NOT NULL	DEFAULT 1,
	VacationHours	INTEGER	NOT NULL	DEFAULT 0,
	SickLeaveHours	INTEGER	NOT NULL	DEFAULT 0,
	CurrentFlag	INTEGER	NOT NULL	DEFAULT 1,
	rowguid	TEXT	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT current_timestamp,
	foreign key (BusinessEntityID) references Person (BusinessEntityID)
);

CREATE TABLE CurrencyRate (
	CurrencyRateID	INTEGER	NULL	PRIMARY KEY,
	CurrencyRateDate	DATETIME	NOT NULL,
	FromCurrencyCode	TEXT	NOT NULL,
	ToCurrencyCode	TEXT	NOT NULL,
	AverageRate	REAL	NOT NULL,
	EndOfDayRate	REAL	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT current_timestamp,
	foreign key (ToCurrencyCode) references Currency (CurrencyCode),
	foreign key (FromCurrencyCode) references Currency (CurrencyCode)
);

CREATE TABLE PurchaseOrderHeader (
	PurchaseOrderID	INTEGER	NULL	PRIMARY KEY,
	RevisionNumber	INTEGER	NOT NULL	DEFAULT 0,
	Status	INTEGER	NOT NULL	DEFAULT 1,
	EmployeeID	INTEGER	NOT NULL,
	VendorID	INTEGER	NOT NULL,
	ShipMethodID	INTEGER	NOT NULL,
	OrderDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP,
	ShipDate	DATETIME	NULL,
	SubTotal	REAL	NOT NULL	DEFAULT 0.0000,
	TaxAmt	REAL	NOT NULL	DEFAULT 0.0000,
	Freight	REAL	NOT NULL	DEFAULT 0.0000,
	TotalDue	REAL	NOT NULL,
	ModifiedDate	DATETIME	NOT NULL	DEFAULT CURRENT_TIMESTAMP,
	foreign key (VendorID) references Vendor (BusinessEntityID),
	foreign key (EmployeeID) references Employee (BusinessEntityID),
	foreign key (ShipMethodID) references ShipMethod (ShipMethodID)
);

### User's Query:
What is the company's second highest salary per hour for employees who are paid monthly?

### Extra Knowledge:
salary received monthly refers to PayFrequency = 1; highest salary per hour refers to Max(Rate);
SELECT Rate FROM EmployeePayHistory WHERE PayFrequency = 1 ORDER BY Rate DESC LIMIT 1, 1