-- -- TABLE tm_index -- DESCRIPTION one row per template, fields are described in http://www.templatemonster.com/webapi/doc/html/ch02s04.html#id2882345 -- owner_id is 0 for tm. -- CARDINALITY -- tm_index <- (1,1) - (0,n) -> tm_types -- tm_index <- (1,1) - (0,n) -> tm_authors CREATE TABLE IF NOT EXISTS `tm_index` ( `id` tinyint (6) NOT NULL auto_increment, `state` tinyint (1) default 0 NULL, `is_hosting` tinyint (1) default 0 NULL, `is_flash` tinyint (1) default 0 NULL, `is_unique` tinyint (1) default 0 NULL, `is_non_unique` tinyint (1) default 0 NULL, `is_unique_corporate` tinyint (1) default 0 NULL, `is_non_unique_corporate` tinyint (1) default 0 NULL, `is_full_size` tinyint (1) default 0 NULL, `is_real_size` tinyint (1) default 0 NULL, `author_id` tinyint (2) default 0 NULL, `type` tinyint (2) default 0 NULL, `owner_id` tinyint (4) default 0 NOT NULL, `price` tinyint (4) default 0 NULL PRIMARY KEY (`id`), KEY `author_id` (`author_id`), KEY `type` (`type`), KEY `owner_id` (`owner_id`) ) ENGINE=InnoDB AUTO_INCREMENT=1; -- -- TABLE tm_details -- DESCRIPTION one row per tm details, this is vertical partionning -- CARDINALITY -- tm_details <- (1,1) - (1,1) -> tm_index CREATE TABLE IF NOT EXISTS `tm_types` ( `id_tm` int (6) default 0 NULL, `exc_price` int (6) default 0 NULL, `downloads` int (6) default 0 NULL, `inserted_date` int (10) default 0 NULL, `keywords` varchar (255) default 0 NULL, `software_required` varchar (255) default 0 NULL KEY (`id_tm`), KEY `keywords` (`keywords`), KEY `software_required` (`software_required`) ) ENGINE=InnoDB AUTO_INCREMENT=1; -- -- TABLE tm_types -- DESCRIPTION one row per type -- CARDINALITY -- tm_types <- (0,n) - (1,1) -> tm_index CREATE TABLE IF NOT EXISTS `tm_types` ( `id` tinyint (3) default NULL, `label` varchar (60) default NULL, PRIMARY KEY (`id`), UNIQUE `label` (`label`) ) ENGINE=InnoDB ; -- -- TABLE tm_authors -- DESCRIPTION one row per author -- CARDINALITY -- tm_authors <- (1,1) - (0,n) -> tm_index CREATE TABLE IF NOT EXISTS `tm_authors` ( `id` tinyint (3) default NULL, `tm_authors` varchar (60) default NULL, PRIMARY KEY (`id`), UNIQUE `tm_authors` (`tm_authors`) ) ENGINE=InnoDB ; -- -- TABLE tm_styles_index -- DESCRIPTION one row per unique style. -- CARDINALITY -- tm_styles_index <- (1,1) - (0,n) -> tm_styles -- tm_styles_index <- (0,n) - (0,n) -> tm_index CREATE TABLE IF NOT EXISTS `tm_styles_index` ( `id` tinyint (3) default NULL, `label` varchar (60) default NULL, PRIMARY KEY (`id`), UNIQUE `label` (`label`) ) ENGINE=InnoDB ; -- -- TABLE tm_styles -- DESCRIPTION one row per style of one template -- CARDINALITY -- tm_styles <- (1,1) - (0,n) -> tm_styles_index -- tm_styles <- (1,1) - (0,n) -> tm_index CREATE TABLE IF NOT EXISTS `tm_styles` ( `id_style` tinyint (2) default NULL, `id_tm` int (6) default NULL, KEY `id_style` (`id_style`), KEY `id_tm` (`id_tm`) ) ENGINE=InnoDB ; -- -- TABLE tm_pages -- DESCRIPTION one row per unique page. -- CARDINALITY -- tm_page <- (0,n) - (1,1) -> tm_screenshots -- tm_page <- (1,1) - (0,n) -> tm_index CREATE TABLE IF NOT EXISTS `tm_pages` ( `id` tinyint (10) default NULL, `id_tm` tinyint (6) default NULL, `label` varchar (60) default NULL, PRIMARY KEY (`id`), KEY (`id_tm`), UNIQUE `label` (`label`) ) ENGINE=InnoDB ; -- -- TABLE tm_screenshots -- DESCRIPTION one row per screenshot -- CARDINALITY -- tm_screenshoots <- (0,1) - (0,n) -> tm_page -- tm_screenshoots <- (1,1) - (0,n) -> tm_index CREATE TABLE IF NOT EXISTS `tm_screenshots` ( `id_tm` tinyint (6) default NULL, `id_page` tinyint (10) default NULL, `uri` varchar (50) default NULL, `filetime` int (10) default NULL, KEY `id_tm` (`id_tm`), KEY `id_page` (`id_page`), UNIQUE `uri` (`uri`) ) ENGINE=InnoDB ;