CREATE TABLE IF NOT EXISTS `#__arismartcontent_config` (
  `ParamName` varchar(100) NOT NULL,
  `ParamValue` varchar(255) NOT NULL,
  PRIMARY KEY (`ParamName`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `#__arismartcontent_formatters` (
  `FormatterId` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `Name` varchar(80) NOT NULL,
  `Data` text NOT NULL,
  `Type` enum('table') DEFAULT NULL,
  PRIMARY KEY (`FormatterId`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `#__arismartcontent_providers` (
  `ProviderId` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `CategoryId` smallint(5) unsigned NOT NULL,
  `Name` varchar(80) NOT NULL,
  `Description` varchar(255) NOT NULL,
  PRIMARY KEY (`ProviderId`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `#__arismartcontent_provider_categories` (
  `CategoryId` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
  `Name` varchar(100) NOT NULL,
  `SystemName` varchar(30) NOT NULL,
  PRIMARY KEY (`CategoryId`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `#__arismartcontent_provider_settings` (
  `Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `Name` varchar(80) NOT NULL,
  `GroupId` int(11) NOT NULL,
  `Params` text NOT NULL,
  `Description` varchar(255) NOT NULL,
  `Created` datetime NOT NULL,
  `CreatedBy` int(10) unsigned NOT NULL,
  `Modified` datetime DEFAULT NULL,
  `ModifiedBy` int(10) unsigned NOT NULL DEFAULT '0',
  `Default` tinyint(1) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `Name` (`Name`),
  KEY `SettingsGroup` (`GroupId`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `#__arismartcontent_provider_settings_groups` (
  `GroupId` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `Name` varchar(80) NOT NULL,
  `SystemName` varchar(30) NOT NULL,
  `ProviderId` int(10) unsigned NOT NULL,
  PRIMARY KEY (`GroupId`),
  KEY `Provider` (`ProviderId`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `#__arismartcontent_provider_sources` (
  `Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `Name` varchar(80) NOT NULL,
  `SourceTypeId` int(11) NOT NULL,
  `SettingsId` int(11) NOT NULL,
  `FormatterId` int(10) unsigned NOT NULL DEFAULT '0',
  `Params` text NOT NULL,
  `Description` varchar(255) NOT NULL,
  `Created` datetime NOT NULL,
  `CreatedBy` int(10) unsigned NOT NULL,
  `Modified` datetime DEFAULT NULL,
  `ModifiedBy` int(10) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `Name` (`Name`,`SourceTypeId`),
  KEY `ProviderSettings` (`SettingsId`),
  KEY `SourceType` (`SourceTypeId`),
  KEY `FormatterId` (`FormatterId`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `#__arismartcontent_provider_source_types` (
  `SourceTypeId` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `ProviderId` int(10) unsigned NOT NULL,
  `Name` varchar(80) NOT NULL,
  `SystemName` varchar(30) NOT NULL,
  `SettingsGroupId` int(10) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`SourceTypeId`),
  KEY `Provider` (`ProviderId`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

-- Data
INSERT INTO `#__arismartcontent_providers` (`ProviderId`, `CategoryId`, `Name`, `Description`) VALUES
(1, 2, 'Flickr', 'Show photos from Flickr service'),
(2, 1, 'Database', 'Show data from databases'),
(3, 1, 'CSV files', 'Show data from CSV files'),
(4, 3, 'Joomla! articles', 'Show Joomla! articles'),
(5, 2, 'Picasa', 'Show images from Picasa service'),
(6, 2, 'Images', 'Show images from local folders'),
(7, 3, 'K2 articles', 'Show K2 articles') ON DUPLICATE KEY UPDATE ProviderId=ProviderId;

INSERT INTO `#__arismartcontent_provider_categories` (`CategoryId`, `Name`, `SystemName`) VALUES
(1, 'Data from database and files', 'data'),
(2, 'Media data', 'media'),
(3, 'Articles', 'articles') ON DUPLICATE KEY UPDATE CategoryId=CategoryId;

INSERT INTO `#__arismartcontent_provider_settings_groups` (`GroupId`, `Name`, `SystemName`, `ProviderId`) VALUES
(1, 'Accounts', 'flickr_account', 1),
(2, 'Connections', 'database_connection', 2) ON DUPLICATE KEY UPDATE GroupId=GroupId;

INSERT INTO `#__arismartcontent_provider_source_types` (`SourceTypeId`, `ProviderId`, `Name`, `SystemName`, `SettingsGroupId`) VALUES
(1, 2, 'Queries', 'database_query', 2),
(2, 3, 'CSV files', 'csv_file', 0),
(3, 1, 'Flickr images', 'flickr_images', 1),
(4, 4, 'Joomla! articles', 'jarticles_articles', 0),
(5, 5, 'Picasa images', 'picasa_images', 0),
(6, 6, 'Local images', 'images_images', 0),
(7, 7, 'K2 articles', 'k2_articles', 0) ON DUPLICATE KEY UPDATE SourceTypeId=SourceTypeId;