CREATE TABLE Link (
  LinkId int(11) NOT NULL auto_increment,
  `Name` varchar(255) NOT NULL default '',
  l1_Name varchar(255) NOT NULL default '',
  l2_Name varchar(255) NOT NULL default '',
  l3_Name varchar(255) NOT NULL default '',
  l4_Name varchar(255) NOT NULL default '',
  l5_Name varchar(255) NOT NULL default '',
  AutomaticFilename tinyint(3) unsigned NOT NULL default '1',
  Description text,
  Url varchar(255) NOT NULL default '',
  CreatedOn int(10) unsigned default NULL,
  Modified int(10) unsigned default NULL,
  Expire int(10) unsigned default NULL,
  Hits double(20,6) NOT NULL default '0.000000',
  CachedRating varchar(10) NOT NULL default '0',
  CachedVotesQty int(11) NOT NULL default '0',
  CachedReviewsQty INT(11) NOT NULL DEFAULT '0',
  CreatedById int(11) NOT NULL default '-1',
  ModifiedById int(11) NOT NULL default '-1',
  Priority int(11) NOT NULL default '0',
  `Status` tinyint(4) NOT NULL default '2',
  EditorsPick 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',
  OrgId int(11) default NULL,
  PRIMARY KEY  (LinkId),
  UNIQUE KEY ResourceId (ResourceId),
  KEY sorting (Priority,`Name`),
  KEY Hits (Hits),
  KEY `Name` (`Name`),
  KEY EditorsPick (EditorsPick),
  KEY CreatedOn (CreatedOn),
  KEY Modified (Modified,CreatedOn),
  KEY `Status` (`Status`)
)
# --------------------------------------------------------
CREATE TABLE LinkValidation (
  LinkValidationId int(11) NOT NULL auto_increment,
  LinkId int(11) NOT NULL default '0',
  ValidationTime double NOT NULL default '0',
  ValidationCode varchar(50) default NULL,
  ValidationStatus tinyint(4) NOT NULL default '0',
  PRIMARY KEY  (LinkValidationId),
  UNIQUE KEY LinkId (LinkId)
)
# --------------------------------------------------------
CREATE TABLE Listings (
  ListingId int(11) NOT NULL auto_increment,
  ListingTypeId int(11) default '0',
  ItemResourceId int(11) default NULL,
  PurchasedOn int(11) default NULL,
  ExpiresOn int(11) default NULL,
  `Status` TINYINT(4) UNSIGNED NOT NULL DEFAULT '2',
  PendingRenewal tinyint(4) NOT NULL default '0',
  RenewalReminderSent tinyint(4) NOT NULL default '0',
  PRIMARY KEY  (ListingId)
)
# --------------------------------------------------------
CREATE TABLE ListingTypes (
  ListingTypeId int(11) NOT NULL auto_increment,
  Name varchar(255) NOT NULL default '',
  Description text NOT NULL,
  Duration int(11) NOT NULL default '0',
  DurationType int(11) NOT NULL default '0',
  OnPurchaseEdPick tinyint(4) NOT NULL default '3',  
  OnPurchaseNew tinyint(4) NOT NULL default '3',
  OnPurchasePop tinyint(4) NOT NULL default '3',
  OnPurchaseHot tinyint(4) NOT NULL default '3',
  OnPurchasePriorityAction tinyint(4) NOT NULL default '0',
  OnPurchasePriorityValue tinyint(4) NOT NULL default '1',
  OnPurchaseAddToCatEnabled tinyint(4) NOT NULL default '0',
  OnPurchaseAddToCat int(11) NOT NULL default '0',
  OnPurchaseStatus tinyint(4) NOT NULL default '3',
  OnExpireEdPick tinyint(4) NOT NULL default '3',
  OnExpireNew tinyint(4) NOT NULL default '3',
  OnExpirePop tinyint(4) NOT NULL default '3',
  OnExpireHot tinyint(4) NOT NULL default '3',
  OnExpirePriorityAction tinyint(4) NOT NULL default '0',
  OnExpirePriorityValue tinyint(4) NOT NULL default '1',
  OnExpireRemoveFromCatEnabled tinyint(4) NOT NULL default '0',
  OnExpireRemoveFromCat int(11) NOT NULL default '0',
  OnExpireStatus tinyint(4) NOT NULL default '3',
  RenewalReminder int(11) NOT NULL default '0',
  EnableBuying tinyint(4) NOT NULL default '0',
  ShopCartName varchar(255) default NULL,
  Price double default NULL,
  Recurring tinyint(4) NOT NULL default '0',
  VirtualProductId int(11) NOT NULL default '0',
  PRIMARY KEY  (ListingTypeId)
)
# --------------------------------------------------------
CREATE TABLE LinkCustomData (
  CustomDataId int(11) NOT NULL auto_increment,
  ResourceId int(10) unsigned NOT NULL default '0',
  KEY ResourceId (ResourceId),
  PRIMARY KEY  (CustomDataId)
)
# --------------------------------------------------------