Create a database, including four tables: student table (Student), course table (Course), score table (Score) and teacher information table (Teacher)

Create a database, including four tables: student table (Student), course table (Course), score table (Score) and teacher information table (Teacher). The structure of the four tables is shown in Table (1-1) ~ Table (4) of Table 1-1, and the data is shown in Table 1-2 ...
Table (1) Student (student table)
attribute name data type can be empty meaning
Sno varchar (20) No student number
Sname varchar (20) No student name
Ssex varchar (20) No student gender
Sbirthday datetime Student birth date
Class varchar (20) Student's class
(Table 2) Course
attribute Can the name data type be empty?
Cno varchar (20) No course number
Cname varchar (20) No course name
Tno varchar (20) No faculty number
Table (3) Score (score)
attribute name data type can be empty meaning
Sno varchar (20) No student number
Cno varchar (20) No course number
Degree Decimal (4,1) grades
(4) Teacher (teacher table)
attribute name data type can be empty meaning
Tno varchar (20) No teacher number
Tname varchar (20) No faculty name
Tsex varchar (20) No
Teacher gender Tbirthday datetime Teacher's birth date
Prof varchar (20) Job title Department varchar (20) No Teacher's
department Department
Table 1-2 Data in the database
Table (1) Student
Sno Sname Ssex Sbirthday class
108 Qiu Dongnan 1977-09-01 95033
105 Kuang Mingnan 1975-10-02 95031
107 Wang Life 1976-01-23 95033
101 Li Junnan 1976-02-20 95033
109 Wang Fangfe 1975-02-10 95031
103 Lu Junnan 1974-06- 03 95031
Table (2) Course
Cno Cname Tno
3-105 Introduction to Computer 825
3-245 Operating System 804
6-166 Digital Circuit 856
9-888 Advanced Mathematics 831
Table (3) Score
Sno Cno Degree
103 3-245 86
105 3- 245 75
109 3-245 68
103 3-105 92
105 3-105 88
109 3-105 76
101 3-105 64
107 3-105 91
108 3-105 78
101 6-166 85
107 6-166 79
108 6-166 81
Table (4) Teacher
Tno Tname Tsex Tbirthday Prof Depart
804 Li Chengnan 1958-12-02 Associate Professor Computer Department
856 Zhang Xunan 1969-03-12 Lecturer Electronic Engineering Department
825 Wang Pingnu 1972-05-05 Teaching Assistant Computer Department
831 Liu Bingnu 1977-08-14 Teaching Assistant Electronic Engineering Department



/*
CREATE DATABASE test;

USE `test`;

CREATE TABLE `course` (
  `Cno` VARCHAR(20) NOT NULL,
  `Cname` VARCHAR(20) NOT NULL,
  `Tno` VARCHAR(20) NOT NULL
) ENGINE=INNODB DEFAULT CHARSET=utf8;

INSERT  INTO `course`(`Cno`,`Cname`,`Tno`) VALUES ('3-105','计算机导论','825'),('3-245','操作系统','804'),('6-166','数字电路','856'),('9-888','高等数学','831');

CREATE TABLE `score` (
  `Sno` VARCHAR(20) NOT NULL,
  `Cno` VARCHAR(20) NOT NULL,
  `Degree` DECIMAL(4,1) DEFAULT NULL
) ENGINE=INNODB DEFAULT CHARSET=utf8;

INSERT  INTO `score`(`Sno`,`Cno`,`Degree`) VALUES ('103','3-245','86.0'),('105','3-245','75.0'),('109','3-245','68.0'),('103','3-105','92.0'),('105','3-105','88.0'),('109','3-105','76.0'),('101','3-105','64.0'),('107','3-105','91.0'),('108','3-105','78.0'),('101','6-166','85.0'),('107','6-166','79.0'),('108','6-166','81.0');

CREATE TABLE `student` (
  `Sno` VARCHAR(20) NOT NULL,
  `Sname` VARCHAR(20) NOT NULL,
  `Ssex` VARCHAR(20) NOT NULL,
  `Sbirthday` DATETIME DEFAULT NULL,
  `class` VARCHAR(20) NOT NULL
) ENGINE=INNODB DEFAULT CHARSET=utf8;

INSERT  INTO `student`(`Sno`,`Sname`,`Ssex`,`Sbirthday`,`class`) VALUES ('108','丘东','男','1977-09-01 00:00:00','95033'),('105','匡明','男','1975-10-02 00:00:00','95031'),('107','王丽','女','1976-01-23 00:00:00','95033'),('101','李军','男','1976-02-20 00:00:00','95033'),('109','王芳','女','1975-02-10 00:00:00','95031'),('103','陆君','男','1974-06-03 00:00:00','95031');

CREATE TABLE `teacher` (
  `Tno` VARCHAR(20) NOT NULL,
  `Tname` VARCHAR(20) NOT NULL,
  `Tsex` VARCHAR(20) NOT NULL,
  `Tbirthday` DATETIME DEFAULT NULL,
  `Prof` VARCHAR(20) DEFAULT NULL,
  `Depart` VARCHAR(20) NOT NULL
) ENGINE=INNODB DEFAULT CHARSET=utf8;

INSERT  INTO `teacher`(`Tno`,`Tname`,`Tsex`,`Tbirthday`,`Prof`,`Depart`) VALUES ('804','李诚','男','1958-12-02 00:00:00','副教授','计算机系'),('856','张旭','男','1969-03-12 00:00:00','讲师','电子工程系'),('825','王萍','女','1972-05-05 00:00:00','助教','计算机系'),('831','刘冰','女','1977-08-14 00:00:00','助教','电子工程系');

Published 238 original articles · praised 429 · 250,000 views

Guess you like

Origin blog.csdn.net/qq_45765882/article/details/105601262