我想知道是否可以创建一个包含引用其他三列值的列的表。示例如下:
CREATE TABLE Students
(
Id INT PRIMARY KEY AUTO_INCREMENT,
Student_Name VARCHAR(25),
Course_Name VARCHAR(25),
First_Mark VARCHAR(25),
Second_Mark VARCHAR(25),
Third_Mark VARCHAR(25)
);
CREATE TABLE Course
(
Id INT PRIMARY KEY AUTO_INCREMENT,
Student_Course_Name VARCHAR(25),
First_Subject VARCHAR(25), <------|*************************************************
Second_Subject VARCHAR(25), <-----| I want to connect values from these columns... *
Third_Subject VARCHAR(25), <------|*************************************************
FOREIGN KEY (Students_Course_Name) references Students (Course_Name)
);
CREATE TABLE Timetable
(
Id INT PRIMARY KEY AUTO_INCREMENT,
Subject_List VARCHAR(25), <-------| *** ...with this column. In other words, I want mentioned columns to be related.
Date DATETIME DEFAULT NULL,
Avarage_Mark INTEGER,
);
这是我想要的:
http://i.stack.imgur.com/zB0AV.png
编辑 2:完整脚本。本练习的目的是创建一个包含学生、科目和考试时间表的数据库。