一,各个表格
1、用户表
CREATE TABLE `t_user` (
`id` varchar(40) NOT NULL,
`username` varchar(20) NOT NULL,
PRIMARY KEY (`id`)
)
2、角色表
CREATE TABLE `t_role` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(20) NOT NULL,
`description` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
)
3、权限表
CREATE TABLE `t_permission` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(20) NOT NULL,
`description` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
)
4、用户角色关系表
CREATE TABLE `user_role` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` varchar(40) NOT NULL,
`role_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `fk_user_role_t_role_1` (`role_id`),
KEY `fk_user_role_t_user_1` (`user_id`),
CONSTRAINT `fk_user_role_t_role_1` FOREIGN KEY (`role_id`) REFERENCES `t_role` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
<