diff --git "a/34\351\230\216\345\206\240\345\256\207/.keep" "b/34\351\230\216\345\206\240\345\256\207/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/34\351\230\216\345\206\240\345\256\207/20230905\346\225\260\346\215\256\345\272\223\350\256\276\350\256\241.md" "b/34\351\230\216\345\206\240\345\256\207/20230905\346\225\260\346\215\256\345\272\223\350\256\276\350\256\241.md" new file mode 100644 index 0000000000000000000000000000000000000000..512b4e7e82c5fcfdc89dcc9f78b5dd162a834df0 --- /dev/null +++ "b/34\351\230\216\345\206\240\345\256\207/20230905\346\225\260\346\215\256\345\272\223\350\256\276\350\256\241.md" @@ -0,0 +1,140 @@ +盘搜搜 vip解析 + +关注招聘信息 + +#### 表与表之间的关系 + +###### 1.一对一的关系 + +​ 将其中任一表中的主键,放到另一个表当主键 + +###### 2.一对多的关系 + +​ 将一所在的表的主键放到多的表当外键 + +###### 3.多对多的关系 + +​ 必须第三张表,将前面两个表的主键放进来当外键 + +![image-20230906200509537](C:\Users\YGY31\AppData\Roaming\Typora\typora-user-images\image-20230906200509537.png) + +```mysql +CREATE DATABASE Faculty CHARSET utf8; +SHOW DATABASES; +USE Faculty; +CREATE TABLE college( + college_id int NOT NULL PRIMARY KEY, #学院编号 + college_name VARCHAR(8) NOT NULL #学院名称 + ); +INSERT INTO college VALUES +(1,'软件工程学院'), +(2,'城乡建筑学院'), +(3,'智能制造学院'); + +CREATE TABLE profession( + profession_id int NOT NULL PRIMARY KEY, #专业编号 + profession_name VARCHAR(10) NOT NULL, #专业名称 + college_id int NOT NULL, #学院编号 + foreign key (college_id) references college (college_id) + ); +INSERT INTO profession VALUES +(01,'后端开发',1), +(02,'新媒体运营',1), +(03,'WEB前端',1); + +CREATE TABLE class( + class_id int NOT NULL PRIMARY KEY, #班级编号 + class_name VARCHAR(10) NOT NULL, #班级名称 + profession_id int NOT NULL, #专业编号 + FOREIGN KEY (profession_id) REFERENCES profession (profession_id) + ); +INSERT INTO class VALUES +(001,'一班',01), +(002,'二班',01), +(003,'三班',01), +(004,'四班',02), +(005,'五班',02), +(006,'六班',02), +(007,'七班',03), +(008,'八班',03), +(009,'九班',03); + +CREATE TABLE student( + student_id int NOT NULL PRIMARY KEY, #学号 + student_name VARCHAR(10) NOT NULL, #学生姓名 + student_six VARCHAR(1) NOT NULL, #学生性别 + student_age int NOT NULL, #学生年龄 + student_address VARCHAR(9) NOT NULL, #学生籍贯 + class_id int NOT NULL, #班级编号 + FOREIGN KEY (class_id) REFERENCES class (class_id) + ); +INSERT INTO student VALUES +(224431347,'张三','男',19,'福建龙岩',001), +(224431348,'李四','女',18,'福建漳州',001), +(224431349,'王五','男',19,'福建莆田',001), +(224431350,'赵六','男',20,'福建厦门',002), +(224431351,'傻七','女',19,'福建福州',002); + +CREATE TABLE subject( + subject_id int NOT NULL PRIMARY KEY, #课程编号 + subject_name VARCHAR(10) NOT NULL #课程名称 + ); +INSERT INTO subject VALUES +(3424,'JAVA'), +(4532,'HTML'), +(6242,'Python'), +(5734,'CSS'); + +CREATE TABLE teacher( + teacher_id int NOT NULL PRIMARY KEY, #教师编号 + teacher_name VARCHAR(10) NOT NULL, #教师姓名 + subject_id int NOT NULL, #课程编号 + FOREIGN KEY (subject_id) REFERENCES subject (subject_id) + ); +INSERT INTO teacher VALUES +(42321,'火星人',3424), +(23421,'水星人',4532), +(87643,'土星人',6242), +(97633,'金星人',5734); + +CREATE TABLE classSchedule( #课程表 + subject_id int NOT NULL PRIMARY KEY, #课程编号 + subject_name VARCHAR(10) NOT NULL, #课程名称 + study_time VARCHAR(10) NOT NULL, #上课时间 + study_address VARCHAR(8) NOT NULL, #上课地址 + teacher_id int NOT NULL #授课教师编号 + ); +INSERT INTO classSchedule VALUES +(3424,'JAVA','8:30','实训8',42321), +(4532,'HTML','10:00','实训8',23421), +(6242,'Python','14:00','实训8',87643), +(5734,'CSS','16:00','实训8',97633); + +CREATE TABLE CourseSelect( #选课表 + subject_id int NOT NULL PRIMARY KEY, #课程编号 + subject_name VARCHAR(10) NOT NULL, #课程名称 + teacher_id int NOT NULL #授课教师编号 + ); +INSERT INTO CourseSelect VALUES +(3424,'JAVA',42321), +(4532,'HTML',23421), +(6242,'Python',87643), +(5734,'CSS',97633); + +CREATE TABLE gradeTable( #成绩表 + student_id int NOT NULL PRIMARY KEY, #学生编号 + student_name VARCHAR(10) NOT NULL, #学生姓名 + Java DOUBLE NOT NULL, #Java成绩 + HTML DOUBLE NOT NULL, #HTML成绩 + Python DOUBLE NOT NULL, #Python成绩 + CSS DOUBLE NOT NULL, #CSS成绩 + FOREIGN KEY (student_id) REFERENCES student (student_id) + ); +INSERT INTO gradeTable VALUES +(224431347,'张三',99,96,98,100), +(224431348,'李四',96,97,89,95), +(224431349,'王五',87,94,93,95), +(224431350,'赵六',98,92,86,90), +(224431351,'傻七',33,66,88,59); +``` + diff --git "a/34\351\230\216\345\206\240\345\256\207/\347\273\230\345\233\276.vsdx" "b/34\351\230\216\345\206\240\345\256\207/\347\273\230\345\233\276.vsdx" new file mode 100644 index 0000000000000000000000000000000000000000..288493fb8546abc85913e1ba3585acdea4ebfd64 Binary files /dev/null and "b/34\351\230\216\345\206\240\345\256\207/\347\273\230\345\233\276.vsdx" differ