需求:
工作中需要计算各省数字专利申请数据,需要首先利用sql的acl参数对数据库的数据框进行预处理,然后通过permission参数进行转换后计算处理,最后利用分类分析法来进行单项计算和归类存储,用于后续的深度数据挖掘。
解决:
sql:
DROP TABLE IF EXISTS acl
;
CREATE TABLE acl
(
id
int NOT NULL,
user_id
int DEFAULT NULL,
permission_id
int DEFAULT NULL,
PRIMARY KEY (id
),
KEY user_id
(user_id
),
KEY permission_id
(permission_id
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
DROP TABLE IF EXISTS permission
;
CREATE TABLE permission
(
id
int NOT NULL AUTO_INCREMENT,
permission
varchar(50) DEFAULT NULL,
PRIMARY KEY (id
)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
DROP TABLE IF EXISTS user
;
CREATE TABLE user
(
id
int NOT NULL AUTO_INCREMENT,
username
varchar(50) DEFAULT NULL,
password
varchar(50) DEFAULT NULL,
PRIMARY KEY (id
)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
初始化数据:
-- 插入用户数据
INSERT INTO User (id, username, password) VALUES (1, 'jack', '1');
INSERT INTO User (id, username, password) VALUES (2, 'rose', '1');
-- 插入权限数据
INSERT INTO Permission (id, permission) VALUES (1, 'device:list');
INSERT INTO Permission (id, permission) VALUES (2, 'device:add');
-- 插入ACL数据
INSERT INTO ACL (id, user_id, permission_id) VALUES (1, 1, 1);
INSERT INTO ACL (id, user_id, permission_id) VALUES (2, 2, 2);
数据来源:各省数字专利申请数据
标签:permission,DEFAULT,acl,VALUES,user,专利申请,NULL,id From: https://blog.51cto.com/u_16035617/7705108