我有一个包含用户、问题和答案的 SQL 。我想要一个连接表来保存问题的速率。许多用户可以对许多问题进行评分。你能告诉我这个 SQL 有什么问题吗?这是SQL:
CREATE TABLE user
(
user_id int(4) NOT NULL,
user_name varchar(255) NOT NULL,
PRIMARY KEY (user_id)
);
CREATE TABLE question
(
question_id int(4) NOT NULL,
question_text longtext NOT NULL,
user_id int(4) NOT NULL,
PRIMARY KEY (question_id),
FOREIGN KEY (user_id) REFERENCES user(user_id)
);
CREATE TABLE answer
(
answer_id int(4) NOT NULL,
user_id int(4)NOT NULL,
question_id int(4) NOT NULL,
PRIMARY KEY (answer_id),
FOREIGN KEY (user_id) REFERENCES user (user_id),
FOREIGN KEY (question_id) REFERENCES question (question_id)
);
CREATE TABLE rate
(
user_id int(4) REFERENCES user NOT NULL,
question_id int(4) REFERENCES question NOT NULL,
rate int(4) NOT NULL
)