Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DROP TABLE IF EXISTS `pages`;
- CREATE TABLE IF NOT EXISTS `pages` (
- `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
- `parent_id` INT(10) UNSIGNED DEFAULT NULL,
- `title` VARCHAR(250) DEFAULT NULL,
- PRIMARY KEY (`id`),
- KEY `parent_id` (`parent_id`)
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- ALTER TABLE `pages`
- ADD CONSTRAINT `pages_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `pages` (`id`) ON DELETE CASCADE;
- DROP TABLE IF EXISTS `pages_paths`;
- CREATE TABLE IF NOT EXISTS `pages_paths` (
- `item_id` INT(10) UNSIGNED DEFAULT NULL,
- `parent_id` INT(10) UNSIGNED DEFAULT NULL,
- `level` tinyint(3) UNSIGNED DEFAULT '0',
- `order` tinyint(3) UNSIGNED DEFAULT '0',
- UNIQUE KEY `item_id_u` (`item_id`,`parent_id`,`level`),
- KEY `item_id_i` (`item_id`),
- KEY `parent_id_i` (`parent_id`)
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- ALTER TABLE `pages_paths`
- ADD CONSTRAINT `pages_paths_ibfk_2` FOREIGN KEY (`parent_id`) REFERENCES `pages` (`id`) ON DELETE CASCADE,
- ADD CONSTRAINT `pages_paths_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `pages` (`id`) ON DELETE CASCADE;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement