CREATE TABLE Addresses (
  AddressId int(11) NOT NULL auto_increment,
  PortalUserId int(11) NOT NULL default '0',
  `To` varchar(255) NOT NULL default '',
  Company varchar(255) NOT NULL default '',
  Phone varchar(255) NOT NULL default '',
  Fax varchar(255) NOT NULL default '',
  Email varchar(255) NOT NULL default '',
  Address1 varchar(255) NOT NULL default '',
  Address2 varchar(255) NOT NULL default '',
  City varchar(255) NOT NULL default '',
  State char(2) NOT NULL default '',
  Zip varchar(20) NOT NULL default '',
  Country char(3) NOT NULL default '',
  LastUsedAsBilling tinyint(4) unsigned NOT NULL default '0',
  LastUsedAsShipping tinyint(4) unsigned NOT NULL default '0',
  IsProfileAddress tinyint(4) NOT NULL default '0',
  PRIMARY KEY  (AddressId)
)
# --------------------------------------------------------
CREATE TABLE Currencies (
  CurrencyId int(11) NOT NULL auto_increment,
  ISO char(3) NOT NULL default '',
  Symbol varchar(255) default NULL,
  SymbolPosition tinyint(4) default NULL,
  Name varchar(255) NOT NULL default '',
  RateToPrimary double NOT NULL default '1',
  Modified int(11) NOT NULL default '0',
  Status smallint(6) NOT NULL default '0',
  IsPrimary smallint(6) NOT NULL default '0',
  Priority int(11) NOT NULL default '0',
  PRIMARY KEY  (CurrencyId)
)
# --------------------------------------------------------
CREATE TABLE GatewayConfigFields (
  GWConfigFieldId int(11) NOT NULL auto_increment,
  SystemFieldName varchar(50) NOT NULL default '',
  FieldName varchar(100) NOT NULL default '',
  ElementType varchar(30) NOT NULL default 'text',
  ValueList mediumtext NOT NULL,
  GatewayId int(11) NOT NULL default '0',
  PRIMARY KEY  (GWConfigFieldId)
)
# --------------------------------------------------------
CREATE TABLE GatewayConfigValues (
  GWConfigValueId int(11) NOT NULL auto_increment,
  GWConfigFieldId int(11) NOT NULL default '0',
  PaymentTypeId int(11) NOT NULL default '0',
  Value varchar(255) default NULL,
  PRIMARY KEY  (GWConfigValueId)
)
# --------------------------------------------------------
CREATE TABLE Gateways (
  GatewayId int(11) NOT NULL auto_increment,
  Name varchar(100) NOT NULL default '',
  ClassName varchar(150) NOT NULL default '',
  ClassFile varchar(255) NOT NULL default '',
  RequireCCFields tinyint(4) NOT NULL default '0',
  PRIMARY KEY  (GatewayId)
)
# --------------------------------------------------------
CREATE TABLE Manufacturers (
  ManufacturerId int(11) NOT NULL auto_increment,
  Name varchar(255) NOT NULL default '',
  Description text NOT NULL,
  URL varchar(255) NOT NULL default '',
  PRIMARY KEY  (ManufacturerId)
)
# --------------------------------------------------------
CREATE TABLE OrderItems (
  OrderItemId int(11) NOT NULL auto_increment,
  OrderId int(11) NOT NULL default '0',
  ProductId int(11) NOT NULL default '0',
  ProductName varchar(255) NOT NULL default '',
  Quantity int(11) NOT NULL default '0',
  QuantityReserved int(11) default NULL,
  FlatPrice decimal(10,4) NOT NULL default '0.0000',
  Price decimal(10,4) NOT NULL default '0.0000',
  BackOrderFlag tinyint(4) default '0',
  Weight double default NULL,
  ShippingTypeId varchar(255) default NULL,
  ItemData text,
  OptionsSalt INT(11) NULL DEFAULT '0',
  SplitShippingGroup int(11) NOT NULL default '0',
  PackageNum int(11) NOT NULL default '0',
  PRIMARY KEY  (OrderItemId),
  KEY OrderId (OrderId)
)
# --------------------------------------------------------
CREATE TABLE Orders (
  OrderId int(11) NOT NULL auto_increment,
  Number mediumint(9) NOT NULL default '0',
  SubNumber smallint(6) NOT NULL default '0',
  Status tinyint(3) unsigned NOT NULL default '0',
  OrderDate int(10) unsigned NOT NULL default '0',
  PortalUserId int(11) NOT NULL default '0',
  OrderIP varchar(30) NOT NULL default '',
  UserComment text NOT NULL,
  AdminComment text NOT NULL,
  BillingTo varchar(255) NOT NULL default '',
  BillingCompany varchar(255) NOT NULL default '',
  BillingPhone varchar(255) NOT NULL default '',
  BillingFax varchar(255) NOT NULL default '',
  BillingEmail varchar(255) NOT NULL default '',
  BillingAddress1 varchar(255) NOT NULL default '',
  BillingAddress2 varchar(255) NOT NULL default '',
  BillingCity varchar(255) NOT NULL default '',
  BillingState varchar(255) NOT NULL default '',
  BillingZip varchar(255) NOT NULL default '',
  BillingCountry varchar(255) NOT NULL default '',
  VAT float NOT NULL default 0,
  VATPercent float NOT NULL default 0,
  PaymentType tinyint(3) unsigned NOT NULL default '0',
  PaymentAccount varchar(255) NOT NULL default '',
  PaymentExpires int(10) unsigned NOT NULL default '0',
  PaymentNameOnCard varchar(255) NOT NULL default '',
  PaymentCCExpDate varchar(5) NOT NULL default '',
  PaymentCardType varchar(255) NOT NULL default '',
  ShippingTo varchar(255) NOT NULL default '',
  ShippingCompany varchar(255) NOT NULL default '',
  ShippingPhone varchar(255) NOT NULL default '',
  ShippingFax varchar(255) NOT NULL default '',
  ShippingEmail varchar(255) NOT NULL default '',
  ShippingAddress1 varchar(255) NOT NULL default '',
  ShippingAddress2 varchar(255) NOT NULL default '',
  ShippingCity varchar(255) NOT NULL default '',
  ShippingState varchar(255) NOT NULL default '',
  ShippingZip varchar(255) NOT NULL default '',
  ShippingCountry varchar(255) NOT NULL default '',
  ShippingType int(11) NOT NULL default '0',
  ShippingCost double(10,4) NOT NULL default '0.0000',
  ShippingCustomerAccount varchar(255) NOT NULL default '',
  ShippingTracking varchar(255) NOT NULL default '',
  ShippingDate int(11) default NULL,
  SubTotal float(10,4) unsigned NOT NULL default '0.0000',
  OriginalAmount decimal(10,4) NOT NULL default '0.0000',
  ShippingOption tinyint(4) default NULL,
  ShippingInfo text,
  CouponId int(11) default NULL,
  CouponDiscount float NOT NULL default '0',
  DiscountTotal decimal(10,4) NOT NULL default '0.0000',
  TransactionStatus tinyint(3) unsigned NOT NULL default '2',
  GWResult1 mediumtext NOT NULL,
  GWResult2 mediumtext NOT NULL,
  AffiliateId int(10) unsigned NOT NULL default '0',
  VisitId int(10) unsigned NOT NULL default '0',
  AffiliateCommission decimal(10,4) NOT NULL default '0.0000',
  ProcessingFee DOUBLE NULL DEFAULT '0.00',
  ShippingTaxable TINYINT( 1 ) NOT NULL DEFAULT '0',
  ProcessingTaxable TINYINT( 1 ) NOT NULL DEFAULT '0',
  IsRecurringBilling tinyint(4) NOT NULL default '0',
  NextCharge int(10) unsigned default NULL,
  GroupId int(10) unsigned NOT NULL default '0',
  ChargeOnNextApprove tinyint(4) NOT NULL default '0',
  ShippingGroupOption tinyint(4) NOT NULL default '0',
  PRIMARY KEY  (OrderId),
  KEY AffiliateId (AffiliateId),
  KEY VisitId (VisitId)
)
# --------------------------------------------------------
CREATE TABLE PaymentTypeCurrencies (
  PaymentTypeCurrencyId int(11) NOT NULL auto_increment,
  PaymentTypeId int(11) NOT NULL default '0',
  CurrencyId int(11) NOT NULL default '0',
  PRIMARY KEY  (PaymentTypeCurrencyId)
)
# --------------------------------------------------------
CREATE TABLE PaymentTypes (
  PaymentTypeId int(11) NOT NULL auto_increment,
  Name varchar(100) NOT NULL default '',
  Description varchar(255) default NULL,
  Instructions text,
  AdminComments text,
  Status int(11) NOT NULL default '0',
  Priority int(11) NOT NULL default '0',
  IsPrimary tinyint(4) NOT NULL default '0',
  BuiltIn smallint(6) NOT NULL default '0',
  GatewayId int(11) NOT NULL default '1',
  PlacedOrdersEdit tinyint(4) NOT NULL default '0',
  ProcessingFee DOUBLE NULL DEFAULT '0.00',
  PRIMARY KEY  (PaymentTypeId)
)
# --------------------------------------------------------
CREATE TABLE Products (
  ProductId int(11) NOT NULL auto_increment,
  Name varchar(255) NOT NULL default '',
  l1_Name varchar(255) default NULL,
  l2_Name varchar(255) default NULL,
  l3_Name varchar(255) default NULL,
  l4_Name varchar(255) default NULL,
  l5_Name varchar(255) default NULL,
  l6_Name varchar(255) default NULL,
  l7_Name varchar(255) default NULL,
  l8_Name varchar(255) default NULL,
  l9_Name varchar(255) default NULL,
  l10_Name varchar(255) default NULL,
  Filename varchar(255) NOT NULL,
  AutomaticFilename tinyint(3) unsigned NOT NULL default '0',
  SKU varchar(255) default NULL,
  Type int(2) default NULL,
  Description text,
  l1_Description text,
  l2_Description text,
  l3_Description text,
  l4_Description text,
  l5_Description text,
  DescriptionExcerpt text,
  l1_DescriptionExcerpt text,
  l2_DescriptionExcerpt text,
  l3_DescriptionExcerpt text,
  l4_DescriptionExcerpt text,
  l5_DescriptionExcerpt text,
  Weight double(10,4) default NULL,
  ManufacturerId int(11) NOT NULL default '0',
  MSRP double default NULL,
  BackOrder int(1) default NULL,
  BackOrderDate int(11) default NULL,
  CreatedOn double NOT NULL default '0',
  Modified double NOT NULL default '0',
  Expire double default NULL,
  Hits double NOT NULL default '0',
  CachedRating decimal(11,10) default NULL,
  CachedVotesQty int(11) NOT NULL default '0',
  CachedReviewsQty int(11) default '0',
  CreatedById int(11) NOT NULL default '0',
  ModifiedById int(11) NOT NULL default '0',
  Priority int(11) NOT NULL default '0',
  Status tinyint(4) default '0',
  EditorsPick tinyint(4) NOT NULL default '0',
  Featured tinyint(4) NOT NULL default '0',
  ResourceId int(11) default NULL,
  HotItem tinyint(4) NOT NULL default '2',
  PopItem tinyint(4) NOT NULL default '2',
  NewItem tinyint(4) NOT NULL default '2',
  InventoryStatus tinyint(4) NOT NULL default '0',
  QtyInStock int(11) default NULL,
  QtyInStockMin int(11) NOT NULL default '0',
  QtyReserved int(11) default NULL,
  QtyBackOrdered int(11) default NULL,
  QtyOnOrder int(11) default NULL,
  InventoryComment text,
  AccessGroupId int(11) default NULL,
  AccessDuration int(11) default NULL,
  AccessDurationType tinyint(4) default NULL,
  AccessStart int(11) default NULL,
  AccessEnd int(11) default NULL,
  Virtual tinyint(4) NOT NULL default '0',
  ProcessingData text,
  PackageContent mediumtext NOT NULL,
  OptionsSelectionMode TINYINT(4) NULL DEFAULT '0',
  HasRequiredOptions TINYINT( 1 ) NOT NULL DEFAULT '0',
  IsRecurringBilling tinyint(3) unsigned NOT NULL default '0',
  ShippingMode tinyint(1) NOT NULL default '0',
  ShippingLimitation text NOT NULL default '',
  PRIMARY KEY  (ProductId),
  KEY ResourceId (ResourceId),
  KEY Hits (Hits),
  KEY Name (Name),
  KEY EditorsPick (EditorsPick),
  KEY CreatedOn (CreatedOn),
  KEY Modified (Modified,CreatedOn),
  KEY Status (Status),
  KEY l1_Name (l1_Name),
  KEY Priority (Priority),
  KEY ManufacturerId (ManufacturerId)
)
# --------------------------------------------------------
CREATE TABLE ProductsCouponItems (
  CouponItemId int(11) NOT NULL auto_increment,
  CouponId int(11) default NULL,
  ItemResourceId int(11) default NULL,
  ItemType tinyint(4) default NULL,
  PRIMARY KEY  (CouponItemId),
  KEY DiscountId (CouponId),
  KEY ItemResourceId (ItemResourceId),
  KEY ItemType (ItemType)
)
# --------------------------------------------------------
CREATE TABLE ProductsCoupons (
  CouponId int(11) NOT NULL auto_increment,
  Status tinyint(4) default NULL,
  Name varchar(255) default NULL,
  Code varchar(255) default NULL,
  Expiration int(11) default NULL,
  GroupId int(11) default NULL,
  Type tinyint(1) default NULL,
  Amount double default NULL,
  LastUsedBy int(11) default NULL,
  LastUsedOn int(11) default NULL,
  NumberOfUses int(11) default NULL,
  PRIMARY KEY  (CouponId),
  KEY Status (Status)
)
# --------------------------------------------------------
CREATE TABLE ProductsDiscountItems (
  DiscountItemId int(11) NOT NULL auto_increment,
  DiscountId int(11) default NULL,
  ItemResourceId int(11) default NULL,
  ItemType tinyint(4) default NULL,
  PRIMARY KEY  (DiscountItemId),
  KEY DiscountId (DiscountId),
  KEY ItemResourceId (ItemResourceId),
  KEY ItemType (ItemType)
)
# --------------------------------------------------------
CREATE TABLE ProductsDiscounts (
  DiscountId int(11) NOT NULL auto_increment,
  Status tinyint(4) default NULL,
  Name varchar(255) default NULL,
  Start int(11) default NULL,
  End int(11) default NULL,
  GroupId int(11) default NULL,
  Type tinyint(1) default NULL,
  Amount double default NULL,
  PRIMARY KEY  (DiscountId),
  KEY Status (Status)
)
# --------------------------------------------------------
CREATE TABLE ProductsPricing (
  PriceId int(11) NOT NULL auto_increment,
  ProductId int(11) NOT NULL default '0',
  MinQty int(11) default NULL,
  MaxQty int(11) default NULL,
  Cost double default NULL,
  Price double default NULL,
  Negotiated tinyint(1) default NULL,
  Points int(11) default NULL,
  AccessDuration int(11) NOT NULL default '0',
  AccessUnit int(11) NOT NULL default '0',
  Description varchar(255) default NULL,
  IsPrimary tinyint(4) NOT NULL default '0',
  PRIMARY KEY  (PriceId),
  KEY ProductId (ProductId)
)
# --------------------------------------------------------
CREATE TABLE ProductFiles (
  FileId INT NOT NULL AUTO_INCREMENT,
  ProductId INT NOT NULL,
  Name VARCHAR(255) NOT NULL,
  Version VARCHAR(100) NOT NULL,
  FilePath VARCHAR(255) NOT NULL,
  RealPath VARCHAR(255) NOT NULL,
  Size INT NOT NULL,
  Status tinyint(4) NOT NULL default '0',
  IsPrimary tinyint(4) NOT NULL default '0',
  Priority smallint(6) NOT NULL default '0',
  AddedOn int(11) NOT NULL default '0',
  AddedById int(11) NOT NULL default '0',
  MIMEType varchar(255) NOT NULL default '',
  PRIMARY KEY (FileId)
)
# --------------------------------------------------------
CREATE TABLE UserFileAccess (
  FileAccessId INT NOT NULL AUTO_INCREMENT,
  ProductId INT NOT NULL,
  PortalUserId INT NOT NULL,
  PRIMARY KEY (FileAccessId)
)
# --------------------------------------------------------
CREATE TABLE UserDownloads (
  DownloadId int(11) NOT NULL auto_increment,
  PortalUserId int(11) NOT NULL default '0',
  Username varchar(255) NOT NULL default '',
  ProductId int(11) NOT NULL default '0',
  ProductName varchar(255) NOT NULL default '',
  FileId int(11) NOT NULL default '0',
  Filename varchar(255) NOT NULL default '',
  IPAddress varchar(100) NOT NULL default '',
  StartedOn int(11) NOT NULL default '0',
  EndedOn int(11) NOT NULL default '0',
  PRIMARY KEY (DownloadId)
)
# --------------------------------------------------------
CREATE TABLE ShippingBrackets (
  BracketId int(11) NOT NULL auto_increment,
  ShippingTypeID int(11) NOT NULL default '0',
  Start double NOT NULL default '0',
  End double NOT NULL default '0',
  PRIMARY KEY  (BracketId),
  KEY ShippingTypeID (ShippingTypeID),
  KEY Start (Start),
  KEY End (End)
)
# --------------------------------------------------------
CREATE TABLE ShippingCosts (
  ShippingCostId int(11) NOT NULL auto_increment,
  ZoneID int(11) NOT NULL default '0',
  BracketId int(11) NOT NULL default '0',
  Flat decimal(10,4) default NULL,
  PerUnit decimal(10,4) default NULL,
  PRIMARY KEY  (ShippingCostId),
  KEY ZoneID (ZoneID),
  KEY BracketId (BracketId)
)
# --------------------------------------------------------
CREATE TABLE ShippingQuoteEngines (
  EngineId int(11) NOT NULL auto_increment,
  Name varchar(255) NOT NULL default '',
  FlatSurcharge double NOT NULL default '0',
  PercentSurcharge double NOT NULL default '0',
  Status smallint(6) NOT NULL default '0',
  Properties text NOT NULL,
  ClassName varchar(255) NOT NULL default '',
  PRIMARY KEY  (EngineId)
)
# --------------------------------------------------------
CREATE TABLE ShippingType (
  ShippingID int(11) NOT NULL auto_increment,
  Code varchar(25) NOT NULL default '',
  Name varchar(100) NOT NULL default '',
  SpeedCode varchar(25) NOT NULL default '',
  LocationFrom int(11) default '0',
  Type int(11) default '0',
  BaseFee double NOT NULL default '0',
  CODFlatSurcharge double NOT NULL default '0',
  CODPercentSurcharge double NOT NULL default '0',
  Status tinyint(4) NOT NULL default '0',
  CostType tinyint(4) NOT NULL default '0',
  ZeroIfEmpty tinyint(4) NOT NULL default '0',
  PrecisionBeforeSep tinyint(4) NOT NULL default '0',
  PrecisionAfterSep tinyint(4) NOT NULL default '0',
  PRIMARY KEY  (ShippingID),
  KEY Type (Type)
)
# --------------------------------------------------------
CREATE TABLE ShippingZones (
  ZoneID int(11) NOT NULL auto_increment,
  ShippingTypeID int(11) NOT NULL default '0',
  Name varchar(100) NOT NULL default '',
  Type int(11) NOT NULL default '1',
  CODallowed smallint(6) NOT NULL default '0',
  PRIMARY KEY  (ZoneID),
  KEY ShippingTypeID (ShippingTypeID),
  KEY Type (Type)
)
# --------------------------------------------------------
CREATE TABLE ShippingZonesDestinations (
  ZoneDestId int(11) NOT NULL auto_increment,
  ShippingZoneId int(11) NOT NULL default '0',
  StdDestId int(11) default '0',
  DestValue varchar(255) default NULL,
  PRIMARY KEY  (ZoneDestId),
  KEY ShippingZoneId (ShippingZoneId),
  KEY StdDestId (StdDestId)
)
# --------------------------------------------------------
CREATE TABLE TaxZones (
  TaxZoneId int(11) NOT NULL auto_increment,
  Name varchar(100) NOT NULL default '',
  Type int(11) NOT NULL default '1',
  TaxValue double NOT NULL default '0',
  ApplyToShipping TINYINT( 1 ) NOT NULL DEFAULT '0',
  ApplyToProcessing TINYINT( 1 ) NOT NULL DEFAULT '0',
  PRIMARY KEY  (TaxZoneId)
)
# --------------------------------------------------------
CREATE TABLE TaxZonesDestinations (
  TaxZoneDestId int(11) NOT NULL auto_increment,
  TaxZoneId int(11) NOT NULL default '0',
  StdDestId int(11) default '0',
  DestValue varchar(255) default NULL,
  PRIMARY KEY  (TaxZoneDestId)
)
# --------------------------------------------------------
CREATE TABLE AffiliatePayments (
  AffiliatePaymentId int(11) NOT NULL auto_increment,
  AffiliateId int(10) unsigned NOT NULL default '0',
  PaymentDate int(10) unsigned NOT NULL default '0',
  Amount decimal(10,2) NOT NULL default '0.00',
  Comment text NOT NULL,
  PaymentReference varchar(255) NOT NULL default '',
  PaymentTypeId int(11) NOT NULL default '0',
  PRIMARY KEY  (AffiliatePaymentId)
)
# --------------------------------------------------------
CREATE TABLE AffiliatePaymentTypes (
  PaymentTypeId int(11) NOT NULL auto_increment,
  Name varchar(255) NOT NULL default '',
  Description text NOT NULL,
  IsPrimary tinyint(4) NOT NULL default '0',
  Status tinyint(4) NOT NULL default '0',
  Priority tinyint(4) NOT NULL default '0',
  PRIMARY KEY  (PaymentTypeId)
)
# --------------------------------------------------------
CREATE TABLE AffiliatePlans (
  AffiliatePlanId int(11) NOT NULL auto_increment,
  Name varchar(255) NOT NULL default '',
  PlanType tinyint(3) unsigned NOT NULL default '0',
  ResetInterval int(10) unsigned NOT NULL default '0',
  PaymentType tinyint(4) NOT NULL default '0',
  MinPaymentAmount varchar(255) NOT NULL default '',
  Enabled tinyint(4) unsigned NOT NULL default '0',
  IsPrimary tinyint(4) NOT NULL default '0',
  PRIMARY KEY  (AffiliatePlanId)
)
# --------------------------------------------------------
CREATE TABLE AffiliatePlansBrackets (
  AffiliateBracketId int(11) NOT NULL auto_increment,
  AffiliatePlanId int(11) NOT NULL default '0',
  FromAmount decimal(10,4) NOT NULL default '0.0000',
  ToAmount decimal(10,4) NOT NULL default '0.0000',
  Percent decimal(3,2) NOT NULL default '0.00',
  PRIMARY KEY  (AffiliateBracketId)
)
# --------------------------------------------------------
CREATE TABLE AffiliatePlansItems (
  AffiliateItemId int(11) NOT NULL auto_increment,
  AffiliatePlanId int(11) NOT NULL default '0',
  ItemResourceId int(10) unsigned NOT NULL default '0',
  ItemType tinyint(4) NOT NULL default '0',
  PRIMARY KEY  (AffiliateItemId)
)
# --------------------------------------------------------
CREATE TABLE Affiliates (
  AffiliateId int(11) NOT NULL auto_increment,
  PortalUserId int(10) unsigned NOT NULL default '0',
  AffiliatePlanId int(10) unsigned NOT NULL default '0',
  AccumulatedAmount decimal(10,2) NOT NULL default '0.00',
  AmountToPay decimal(10,2) NOT NULL default '0.00',
  LastPaymentDate int(11) NOT NULL default '0',
  LastOrderDate int(11) NOT NULL default '0',
  Status tinyint(4) NOT NULL default '0',
  AffiliateCode varchar(30) NOT NULL default '',
  ItemsSold int(10) unsigned NOT NULL default '0',
  PaymentTypeId int(11) NOT NULL default '0',
  SSN varchar(100) NOT NULL default '',
  Comments text NOT NULL,
  CreatedOn int(11) NOT NULL default '0',
  PRIMARY KEY  (AffiliateId),
  UNIQUE KEY PortalUserId (PortalUserId),
  UNIQUE KEY AffiliateCode (AffiliateCode),
  KEY LastOrderDate (LastOrderDate)
)
# --------------------------------------------------------
CREATE TABLE ProductOptionCombinations (
  CombinationId int(11) NOT NULL auto_increment,
  ProductId int(11) NOT NULL default '0',
  Combination text NOT NULL,
  CombinationCRC int(11) NOT NULL default '0',
  PriceType tinyint(1) default NULL,
  Price float default NULL,
  WeightType tinyint(1) default NULL,
  Weight float default NULL,
  Availability tinyint(1) default NULL,
  Priority int(11) NOT NULL default '0',
  PRIMARY KEY  (CombinationId)
)
# --------------------------------------------------------
CREATE TABLE ProductOptions (
  ProductOptionId int(11) NOT NULL auto_increment,
  ProductId int(11) NOT NULL default '0',
  Name varchar(255) NOT NULL default '',
  OptionType tinyint(4) default NULL,
  Required tinyint(4) NOT NULL default '0',
  Listable tinyint(4) NOT NULL default '0',
  Priority int(11) NOT NULL default '0',
  `Values` text,
  Prices text,
  PriceTypes text,
  PRIMARY KEY  (ProductOptionId),
  KEY ProductId (ProductId,Priority)
)
# --------------------------------------------------------
CREATE TABLE ProductsCustomData (
  CustomDataId int(11) NOT NULL auto_increment,
  ResourceId int(10) unsigned NOT NULL default '0',
  KEY ResourceId (ResourceId),
  PRIMARY KEY  (CustomDataId)
)
# --------------------------------------------------------