CREATE TABLE IF NOT EXISTS `availability_booking` (
  `ID` int(11) NOT NULL auto_increment,
  `Resource_ID` int(11) default NULL,
  `Date_From` date default NULL,
  `Date_To` date default NULL,
  `Nights` tinyint(4) NOT NULL default '1',
  `Notes` longtext,
  `Unavailable` tinyint(1) NOT NULL default '0',
  `Price` varchar(255) default NULL,
  `Name` varchar(255) default NULL,
  `Address_1` varchar(255) default NULL,
  `Address_2` varchar(255) default NULL,
  `Town` varchar(255) default NULL,
  `County` varchar(255) default NULL,
  `Postcode` varchar(255) default NULL,
  `Country` varchar(255) default NULL,
  `Telephone` varchar(255) default NULL,
  `Email` varchar(255) default NULL,
  `Created` datetime default NULL,
  `Updated` datetime default NULL,
  PRIMARY KEY  (`ID`),
  KEY `BookableID` (`Resource_ID`,`Date_From`,`Date_To`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;

CREATE TABLE IF NOT EXISTS `availability_resource` (
  `ID` int(11) NOT NULL auto_increment,
  `Availability_Resource_Group_ID` int(1) default NULL,
  `Title` varchar(255) default NULL,
  `Order_By` int(11) default NULL,
  `Created` datetime default NULL,
  `Updated` datetime default NULL,
  PRIMARY KEY  (`ID`),
  KEY `Order_By` (`Order_By`),
  KEY `Availability_Resource_Group_ID` (`Availability_Resource_Group_ID`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;

CREATE TABLE IF NOT EXISTS `availability_resource_period` (
  `ID` int(11) NOT NULL auto_increment,
  `Title` varchar(255) default NULL,
  `Availability_Resource_ID` int(11) default NULL,
  `Order_By` int(11) default NULL,
  `Created` datetime default NULL,
  `Updated` datetime default NULL,
  PRIMARY KEY  (`ID`),
  KEY `Title` (`Title`),
  KEY `Availability_Resource_ID` (`Availability_Resource_ID`,`Order_By`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;

CREATE TABLE IF NOT EXISTS `availability_resource_price` (
  `ID` int(11) NOT NULL auto_increment,
  `Title` varchar(255) default NULL,
  `Availability_Resource_ID` int(11) default NULL,
  `Availability_Resource_Period_ID` int(11) default NULL,
  `Date` date default NULL,
  `Created` datetime default NULL,
  `Updated` datetime default NULL,
  PRIMARY KEY  (`ID`),
  KEY `Availability_Resource_ID` (`Availability_Resource_ID`,`Availability_Resource_Period_ID`,`Date`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;