CREATE TABLE category id int 11 NOT NULL AUTO_INCREMENT parent_id int

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
CREATE TABLE `category` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`parent_id` int(11) DEFAULT NULL,
`rewrite` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`top` int(11) DEFAULT NULL,
`image` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`sort_order` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `fk-category-parent_id-category-id` (`parent_id`),
CONSTRAINT `fk-category-parent_id-category-id` FOREIGN KEY (`parent_id`) REFERENCES `category` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci