CREATE TABLE `page` ( `id` int, `type` varchar(255), `status` varchar(255), `template` varchar(255), `callback` varchar(255), `parent_id` int, `sort_order` varchar(255), `date_created` datetime, `date_modified` datetime, `site_id` int, FOREIGN KEY(`parent_id`) REFERENCES `page` (`id`), FOREIGN KEY(`site_id`) REFERENCES `site` (`id`) ); CREATE TABLE `language` ( `id` int, `name` varchar(255), `iso_code` varchar(255), `sort_order` varchar(255), `group` varchar(255) ); CREATE TABLE `page_texts` ( `id` int, `page_id` int, `language_id` int, `slug` varchar(255), `title` varchar(255), `content` longtext, FOREIGN KEY(`page_id`) REFERENCES `page` (`id`), FOREIGN KEY(`language_id`) REFERENCES `language` (`id`) ); CREATE TABLE `term` ( `id` int, `taxonomy` varchar(255), `sort_order` varchar(255), `date_created` datetime, `date_modified` datetime, FOREIGN KEY(`date_modified`) REFERENCES `date` (`modified`) ); CREATE TABLE `term_texts` ( `id` int, `term_id` int, `language_id` int, `slug` varchar(255), `title` varchar(255), `content` longtext, FOREIGN KEY(`term_id`) REFERENCES `term` (`id`), FOREIGN KEY(`language_id`) REFERENCES `language` (`id`) ); CREATE TABLE `page_terms` ( `id` int, `page_id` int, `term_id` int, `sort_order` varchar(255), FOREIGN KEY(`page_id`) REFERENCES `page` (`id`), FOREIGN KEY(`term_id`) REFERENCES `term` (`id`), FOREIGN KEY(`sort_order`) REFERENCES `sort` (`order`) ); CREATE TABLE `attachment` ( `id` int, `path` varchar(255), `page_id` int, `sort_order` varchar(255), `date_created` datetime, `date_modified` datetime, FOREIGN KEY(`page_id`) REFERENCES `page` (`id`), FOREIGN KEY(`date_modified`) REFERENCES `date` (`modified`) ); CREATE TABLE `attachment_texts` ( `id` int, `attachment_id` int, `language_id` int, FOREIGN KEY(`attachment_id`) REFERENCES `attachment` (`id`), FOREIGN KEY(`language_id`) REFERENCES `language` (`id`) ); CREATE TABLE `term_attachments` ( `id` int, `term_id` int, `attachment_id` int, `sort_order` varchar(255), FOREIGN KEY(`term_id`) REFERENCES `term` (`id`), FOREIGN KEY(`attachment_id`) REFERENCES `attachment` (`id`), FOREIGN KEY(`sort_order`) REFERENCES `sort` (`order`) ); CREATE TABLE `page_attachments` ( `id` int, `page_id` int, `attachment_id` int, `sort_order` varchar(255), FOREIGN KEY(`page_id`) REFERENCES `page` (`id`), FOREIGN KEY(`attachment_id`) REFERENCES `attachment` (`id`), FOREIGN KEY(`sort_order`) REFERENCES `sort` (`order`) ); CREATE TABLE `comment` ( `id` int, `author_name` varchar(255), `author_email` varchar(255), `author_url` varchar(255), `author_ip` varchar(255), `content` varchar(255), `status` varchar(255), `page_id` int, `language_id` int, `date_created` datetime, FOREIGN KEY(`page_id`) REFERENCES `page` (`id`), FOREIGN KEY(`language_id`) REFERENCES `language` (`id`) ); CREATE TABLE `site` ( `id` int, `name` varchar(255), `domain` varchar(255), `basepath` varchar(255), `is_active` bool, `is_maintenance` bool );