diff --git "a/\345\271\262\347\272\257\346\254\243/0908\345\237\272\344\272\216\350\247\222\350\211\262\347\232\204\350\256\277\351\227\256\346\216\247\345\210\266\357\274\210RBAC\357\274\211.md" "b/\345\271\262\347\272\257\346\254\243/0908\345\237\272\344\272\216\350\247\222\350\211\262\347\232\204\350\256\277\351\227\256\346\216\247\345\210\266\357\274\210RBAC\357\274\211.md" new file mode 100644 index 0000000000000000000000000000000000000000..eda8dff7cfb89836fcc214eef39f61098f0ac6bd --- /dev/null +++ "b/\345\271\262\347\272\257\346\254\243/0908\345\237\272\344\272\216\350\247\222\350\211\262\347\232\204\350\256\277\351\227\256\346\216\247\345\210\266\357\274\210RBAC\357\274\211.md" @@ -0,0 +1,669 @@ +# 0908基于角色的访问控制(RBAC) + +## 一、什么是RBAC(Role-Based Access Control)? + +1. 基本思想是,对于系统操作的各种权限不是直接授予具体的用户,而是在用户集合与权限集合之间建立一个角色集合,,每一种角色对应一组相应的权限。一旦用户被分配了适当的角色后,该用户就拥有此角色的所有操作权限。 +2. 好处:不必在每次创建用户时都进行分配权限的操作,只要分配用户相应的角色即可。 + +## 二、为什么要用RBAC? + +不同的人拥有不同的权限,使得系统更加合理,分级治之! + +## 三、RBAC的数据库设计 + +数据库表设计思路图 + +CDM + +![image-20240908173819967](https://gitee.com/gcxxl/note-sheet-bed/raw/master/images/202409081738095.png) + +LDM + +![image-20240908173901443](https://gitee.com/gcxxl/note-sheet-bed/raw/master/images/202409081739519.png) + +PDM + +![image-20240908173936962](https://gitee.com/gcxxl/note-sheet-bed/raw/master/images/202409081739025.png) + +SQL语句 + +```sql +CREATE DATABASE RBAC; +USE RBAC; +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2024/9/8 17:55:29 */ +/*==============================================================*/ + + +drop table if exists class; + +drop table if exists course; + +drop table if exists facetoface; + +drop table if exists hand; + +drop table if exists inforation; + +drop table if exists permissions; + +drop table if exists roles; + +drop table if exists score; + +drop table if exists sq; + +drop table if exists student; + +drop table if exists teacher; + +drop table if exists tq; + +/*==============================================================*/ +/* Table: class */ +/*==============================================================*/ +create table class +( + classid int not null, + classname varchar(20), + primary key (classid) +); + +/*==============================================================*/ +/* Table: course */ +/*==============================================================*/ +create table course +( + courseid int not null, + coursename varchar(25), + primary key (courseid) +); + +/*==============================================================*/ +/* Table: facetoface */ +/*==============================================================*/ +create table facetoface +( + classid int not null, + courseid int not null, + primary key (classid, courseid) +); + +/*==============================================================*/ +/* Table: hand */ +/*==============================================================*/ +create table hand +( + roleid int not null, + pid int not null, + primary key (roleid, pid) +); + +/*==============================================================*/ +/* Table: inforation */ +/*==============================================================*/ +create table inforation +( + userid int not null, + username varchar(15), + age int, + gender int, + tall int, + primary key (userid) +); + +/*==============================================================*/ +/* Table: permissions */ +/*==============================================================*/ +create table permissions +( + pid int not null, + paction varchar(15), + primary key (pid) +); + +/*==============================================================*/ +/* Table: roles */ +/*==============================================================*/ +create table roles +( + student varchar(10), + teacher varchar(10), + roleid int not null, + userid int not null, + primary key (roleid) +); + +/*==============================================================*/ +/* Table: score */ +/*==============================================================*/ +create table score +( + sid int not null, + studentid int not null, + courseid int not null, + "student-id" int, + "course-id" int, + score int, + primary key (sid) +); + +/*==============================================================*/ +/* Table: sq */ +/*==============================================================*/ +create table sq +( + pid int not null, + studentid int not null, + primary key (pid, studentid) +); + +/*==============================================================*/ +/* Table: student */ +/*==============================================================*/ +create table student +( + studentid int not null, + classid int not null, + studentname varchar(15), + primary key (studentid) +); + +/*==============================================================*/ +/* Table: teacher */ +/*==============================================================*/ +create table teacher +( + teacherid int not null, + teachername varchar(15), + primary key (teacherid) +); + +/*==============================================================*/ +/* Table: tq */ +/*==============================================================*/ +create table tq +( + teacherid int not null, + pid int not null, + primary key (teacherid, pid) +); + +alter table facetoface add constraint FK_facetoface foreign key (classid) + references class (classid) on delete restrict on update restrict; + +alter table facetoface add constraint FK_facetoface2 foreign key (courseid) + references course (courseid) on delete restrict on update restrict; + +alter table hand add constraint FK_hand foreign key (roleid) + references roles (roleid) on delete restrict on update restrict; + +alter table hand add constraint FK_hand2 foreign key (pid) + references permissions (pid) on delete restrict on update restrict; + +alter table roles add constraint FK_roleinfo foreign key (userid) + references inforation (userid) on delete restrict on update restrict; + +alter table score add constraint FK_more foreign key (courseid) + references course (courseid) on delete restrict on update restrict; + +alter table score add constraint FK_serch foreign key (studentid) + references student (studentid) on delete restrict on update restrict; + +alter table sq add constraint FK_sq foreign key (pid) + references permissions (pid) on delete restrict on update restrict; + +alter table sq add constraint FK_sq2 foreign key (studentid) + references student (studentid) on delete restrict on update restrict; + +alter table student add constraint FK_join foreign key (classid) + references class (classid) on delete restrict on update restrict; + +alter table tq add constraint FK_tq foreign key (teacherid) + references teacher (teacherid) on delete restrict on update restrict; + +alter table tq add constraint FK_tq2 foreign key (pid) + references permissions (pid) on delete restrict on update restrict; + +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2024/9/8 17:55:29 */ +/*==============================================================*/ + + +drop table if exists class; + +drop table if exists course; + +drop table if exists facetoface; + +drop table if exists hand; + +drop table if exists inforation; + +drop table if exists permissions; + +drop table if exists roles; + +drop table if exists score; + +drop table if exists sq; + +drop table if exists student; + +drop table if exists teacher; + +drop table if exists tq; + +/*==============================================================*/ +/* Table: class */ +/*==============================================================*/ +create table class +( + classid int not null, + classname varchar(20), + primary key (classid) +); + +/*==============================================================*/ +/* Table: course */ +/*==============================================================*/ +create table course +( + courseid int not null, + coursename varchar(25), + primary key (courseid) +); + +/*==============================================================*/ +/* Table: facetoface */ +/*==============================================================*/ +create table facetoface +( + classid int not null, + courseid int not null, + primary key (classid, courseid) +); + +/*==============================================================*/ +/* Table: hand */ +/*==============================================================*/ +create table hand +( + roleid int not null, + pid int not null, + primary key (roleid, pid) +); + +/*==============================================================*/ +/* Table: inforation */ +/*==============================================================*/ +create table inforation +( + userid int not null, + username varchar(15), + age int, + gender int, + tall int, + primary key (userid) +); + +/*==============================================================*/ +/* Table: permissions */ +/*==============================================================*/ +create table permissions +( + pid int not null, + paction varchar(15), + primary key (pid) +); + +/*==============================================================*/ +/* Table: roles */ +/*==============================================================*/ +create table roles +( + student varchar(10), + teacher varchar(10), + roleid int not null, + userid int not null, + primary key (roleid) +); + +/*==============================================================*/ +/* Table: score */ +/*==============================================================*/ +create table score +( + sid int not null, + studentid int not null, + courseid int not null, + "student-id" int, + "course-id" int, + score int, + primary key (sid) +); + +/*==============================================================*/ +/* Table: sq */ +/*==============================================================*/ +create table sq +( + pid int not null, + studentid int not null, + primary key (pid, studentid) +); + +/*==============================================================*/ +/* Table: student */ +/*==============================================================*/ +create table student +( + studentid int not null, + classid int not null, + studentname varchar(15), + primary key (studentid) +); + +/*==============================================================*/ +/* Table: teacher */ +/*==============================================================*/ +create table teacher +( + teacherid int not null, + teachername varchar(15), + primary key (teacherid) +); + +/*==============================================================*/ +/* Table: tq */ +/*==============================================================*/ +create table tq +( + teacherid int not null, + pid int not null, + primary key (teacherid, pid) +); + +alter table facetoface add constraint FK_facetoface foreign key (classid) + references class (classid) on delete restrict on update restrict; + +alter table facetoface add constraint FK_facetoface2 foreign key (courseid) + references course (courseid) on delete restrict on update restrict; + +alter table hand add constraint FK_hand foreign key (roleid) + references roles (roleid) on delete restrict on update restrict; + +alter table hand add constraint FK_hand2 foreign key (pid) + references permissions (pid) on delete restrict on update restrict; + +alter table roles add constraint FK_roleinfo foreign key (userid) + references inforation (userid) on delete restrict on update restrict; + +alter table score add constraint FK_more foreign key (courseid) + references course (courseid) on delete restrict on update restrict; + +alter table score add constraint FK_serch foreign key (studentid) + references student (studentid) on delete restrict on update restrict; + +alter table sq add constraint FK_sq foreign key (pid) + references permissions (pid) on delete restrict on update restrict; + +alter table sq add constraint FK_sq2 foreign key (studentid) + references student (studentid) on delete restrict on update restrict; + +alter table student add constraint FK_join foreign key (classid) + references class (classid) on delete restrict on update restrict; + +alter table tq add constraint FK_tq foreign key (teacherid) + references teacher (teacherid) on delete restrict on update restrict; + +alter table tq add constraint FK_tq2 foreign key (pid) + references permissions (pid) on delete restrict on update restrict; + +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2024/9/8 17:55:29 */ +/*==============================================================*/ + + +drop table if exists class; + +drop table if exists course; + +drop table if exists facetoface; + +drop table if exists hand; + +drop table if exists inforation; + +drop table if exists permissions; + +drop table if exists roles; + +drop table if exists score; + +drop table if exists sq; + +drop table if exists student; + +drop table if exists teacher; + +drop table if exists tq; + +/*==============================================================*/ +/* Table: class */ +/*==============================================================*/ +create table class +( + classid int not null, + classname varchar(20), + primary key (classid) +); + +/*==============================================================*/ +/* Table: course */ +/*==============================================================*/ +create table course +( + courseid int not null, + coursename varchar(25), + primary key (courseid) +); + +/*==============================================================*/ +/* Table: facetoface */ +/*==============================================================*/ +create table facetoface +( + classid int not null, + courseid int not null, + primary key (classid, courseid) +); + +/*==============================================================*/ +/* Table: hand */ +/*==============================================================*/ +create table hand +( + roleid int not null, + pid int not null, + primary key (roleid, pid) +); + +/*==============================================================*/ +/* Table: inforation */ +/*==============================================================*/ +create table inforation +( + userid int not null, + username varchar(15), + age int, + gender int, + tall int, + primary key (userid) +); + +/*==============================================================*/ +/* Table: permissions */ +/*==============================================================*/ +create table permissions +( + pid int not null, + paction varchar(15), + primary key (pid) +); + +/*==============================================================*/ +/* Table: roles */ +/*==============================================================*/ +create table roles +( + student varchar(10), + teacher varchar(10), + roleid int not null, + userid int not null, + primary key (roleid) +); + +/*==============================================================*/ +/* Table: score */ +/*==============================================================*/ +use rbac; +create table score +( + sid int not null, + studentid int not null, + courseid int not null, + score int, + primary key (sid) +); + +/*==============================================================*/ +/* Table: sq */ +/*==============================================================*/ +create table sq +( + pid int not null, + studentid int not null, + primary key (pid, studentid) +); + +/*==============================================================*/ +/* Table: student */ +/*==============================================================*/ +create table student +( + studentid int not null, + classid int not null, + studentname varchar(15), + primary key (studentid) +); + +/*==============================================================*/ +/* Table: teacher */ +/*==============================================================*/ +create table teacher +( + teacherid int not null, + teachername varchar(15), + primary key (teacherid) +); + +/*==============================================================*/ +/* Table: tq */ +/*==============================================================*/ +create table tq +( + teacherid int not null, + pid int not null, + primary key (teacherid, pid) +); + +alter table facetoface add constraint FK_facetoface foreign key (classid) + references class (classid) on delete restrict on update restrict; + +alter table facetoface add constraint FK_facetoface2 foreign key (courseid) + references course (courseid) on delete restrict on update restrict; + +alter table hand add constraint FK_hand foreign key (roleid) + references roles (roleid) on delete restrict on update restrict; + +alter table hand add constraint FK_hand2 foreign key (pid) + references permissions (pid) on delete restrict on update restrict; + +alter table roles add constraint FK_roleinfo foreign key (userid) + references inforation (userid) on delete restrict on update restrict; + +alter table score add constraint FK_more foreign key (courseid) + references course (courseid) on delete restrict on update restrict; + +alter table score add constraint FK_serch foreign key (studentid) + references student (studentid) on delete restrict on update restrict; + +alter table sq add constraint FK_sq foreign key (pid) + references permissions (pid) on delete restrict on update restrict; + +alter table sq add constraint FK_sq2 foreign key (studentid) + references student (studentid) on delete restrict on update restrict; + +alter table student add constraint FK_join foreign key (classid) + references class (classid) on delete restrict on update restrict; + +alter table tq add constraint FK_tq foreign key (teacherid) + references teacher (teacherid) on delete restrict on update restrict; + +alter table tq add constraint FK_tq2 foreign key (pid) + references permissions (pid) on delete restrict on update restrict; + +INSERT INTO roles (student,teacher,roleid,userid) VALUES +('张三','王老师',1,1), +('李三','李老师',2,2), +('王三','张老师',3,3); +INSERT INTO permissions (pid,paction) VALUES +(1,'增加'), +(2,'修改'), +(3,'查看'); + +INSERT INTO inforation (userid,username,age,gender,tall) VALUES +(100,'张三',19,1,180), +(200,'李三',20,1,181), +(300,'王三',18,1,182), +(400,'张老师',30,0,170); + +INSERT INTO hand (roleid,pid) VALUES +(1,11), +(2,22), +(3,333); + +INSERT INTO class (classid,classname) VALUES +(1,'软件技术1班'), +(2,'软件技术2班'), +(3,'软件技术3班'); + +INSERT INTO course (courseid,coursename) VALUES +(10,'语文'), +(20,'数学'), +(30,'英语'); + +INSERT INTO facetoface (classid,courseid) VALUES +(1,10), +(2,20), +(3,30); + +INSERT INTO score (sid,studentid,courseid,score) VALUES +(1,19,10,80), +(2,20,20,81), +(3,18,30,92); + +INSERT INTO student (studentid,classid,studentname) VALUES +(1,19,'张三'), +(2,20,'李三'), +(3,18,'王三'); + +学生张三想要查询他的语文成绩; +select st.studentname,co.coursename,sc.score from score sc inner join course co on sc.courseid = co.courseid inner join student st on st.studentid = sc.studentid where co.coursename='语文'; + +``` + diff --git "a/\345\271\262\347\272\257\346\254\243/2024.0907 \344\270\211\345\244\247\350\214\203\345\274\217\357\274\214git\347\232\204\344\275\277\347\224\250\345\217\212\345\205\266picgo\343\200\201node.js.md" "b/\345\271\262\347\272\257\346\254\243/2024.0907 \344\270\211\345\244\247\350\214\203\345\274\217\357\274\214git\347\232\204\344\275\277\347\224\250\345\217\212\345\205\266picgo\343\200\201node.js.md" new file mode 100644 index 0000000000000000000000000000000000000000..844ec41f052554f17332c77d969a2f5e418f08ed --- /dev/null +++ "b/\345\271\262\347\272\257\346\254\243/2024.0907 \344\270\211\345\244\247\350\214\203\345\274\217\357\274\214git\347\232\204\344\275\277\347\224\250\345\217\212\345\205\266picgo\343\200\201node.js.md" @@ -0,0 +1,52 @@ +# 2024.0907 三大范式,git的使用及其picgo、node.js + +## 一、三大范式 + +- 1nf +- 概念:要求数据库表中的每一个字段都只能包含原子值 +- 举例 + +![image-20240907211128638](https://gitee.com/gcxxl/note-sheet-bed/raw/master/images/202409072111714.png) + +这是明显错误的,应该将地址分到不能再分,取消数据冗余,如 + +![image-20240907211340087](https://gitee.com/gcxxl/note-sheet-bed/raw/master/images/202409072113129.png) + +- 2nf +- 概念:在1nf的基础上,要求表中的每个非主键字段都完全依赖于主键,即取消部分依赖 +- 举例 + +![image-20240907211805625](https://gitee.com/gcxxl/note-sheet-bed/raw/master/images/202409072118660.png) + +将上面表格拆除即取消部分依赖如 + +![image-20240907211923609](https://gitee.com/gcxxl/note-sheet-bed/raw/master/images/202409072119625.png) + +![image-20240907211952847](https://gitee.com/gcxxl/note-sheet-bed/raw/master/images/202409072119864.png) + +- 3nf + +- 概念:在满足2nf的基础上,不存在传递依赖 + +- 举例:如果A是主键,B依赖于A,而C依赖于B,不直接依赖于主键则视为依赖传递 + + # 二、图床及picgo插件的使用,实现笔记自动上传图片到gitee + + 1. gitee当图床:病床,矿床,床是一个容器,图床一般指网络某个云服务。可用来存放图片,并通过url访问这上图片, + + 1. 新建仓库,用来存图片 + 2. 获取私人令牌 + + 2. 安装picgo + + 1. 安装gitee uploader的插件 + + (安装之前首先下载node.js) + + 2. 设置这个插件,仓库的地址,私人令牌 + + ![image-20240907212800746](https://gitee.com/gcxxl/note-sheet-bed/raw/master/images/202409072128766.png) + + + + \ No newline at end of file