某期刊的在线投稿审稿管理系统 功能要求: 实现作者、审稿人的信息管理; 实现稿件类型、稿件信息的管理; 实现稿件的审阅过程管理; 实现稿费、审稿费和版面费的管理; 创建存储过程统计指定作者的稿件信息; 创建触发器当收到审稿费时自动修改审稿费收到标记为“是”; 创建规则使得作者的E-Mail必须满足电子邮件的基本格式; 建立数据库相关表之间的参照完整性约束。写出MySQL8的建表语句
时间: 2024-02-13 16:04:38 浏览: 177
好的,以下是根据题目要求的 MySQL 8 建表语句:
1. 作者信息表(authors)
```
CREATE TABLE authors (
author_id INT PRIMARY KEY,
author_name VARCHAR(50) NOT NULL,
author_email VARCHAR(50) NOT NULL CHECK(author_email REGEXP '^[^@]+@[^@]+\.[^@]+$')
);
```
2. 审稿人信息表(reviewers)
```
CREATE TABLE reviewers (
reviewer_id INT PRIMARY KEY,
reviewer_name VARCHAR(50) NOT NULL,
reviewer_email VARCHAR(50) NOT NULL CHECK(reviewer_email REGEXP '^[^@]+@[^@]+\.[^@]+$')
);
```
3. 稿件类型表(paper_types)
```
CREATE TABLE paper_types (
type_id INT PRIMARY KEY,
type_name VARCHAR(50) NOT NULL
);
```
4. 稿件信息表(papers)
```
CREATE TABLE papers (
paper_id INT PRIMARY KEY,
paper_title VARCHAR(100) NOT NULL,
paper_type_id INT NOT NULL,
author_id INT NOT NULL,
submitted_date DATE NOT NULL,
CONSTRAINT fk_paper_author FOREIGN KEY (author_id) REFERENCES authors(author_id),
CONSTRAINT fk_paper_type FOREIGN KEY (paper_type_id) REFERENCES paper_types(type_id)
);
```
5. 审阅过程管理表(reviews)
```
CREATE TABLE reviews (
review_id INT PRIMARY KEY,
paper_id INT NOT NULL,
reviewer_id INT NOT NULL,
review_date DATE NOT NULL,
review_result INT NOT NULL, -- 1:通过;2:拒绝;3:修改后再次提交
review_comment VARCHAR(500),
CONSTRAINT fk_review_paper FOREIGN KEY (paper_id) REFERENCES papers(paper_id),
CONSTRAINT fk_review_reviewer FOREIGN KEY (reviewer_id) REFERENCES reviewers(reviewer_id)
);
```
6. 稿费管理表(payment)
```
CREATE TABLE payment (
payment_id INT PRIMARY KEY,
paper_id INT NOT NULL,
author_id INT NOT NULL,
payment_date DATE NOT NULL,
paper_fee FLOAT NOT NULL,
review_fee FLOAT NOT NULL,
layout_fee FLOAT NOT NULL,
review_received CHAR(1) NOT NULL DEFAULT '否', -- 是否收到审稿费,触发器将其更新为'是'
CONSTRAINT fk_payment_paper FOREIGN KEY (paper_id) REFERENCES papers(paper_id),
CONSTRAINT fk_payment_author FOREIGN KEY (author_id) REFERENCES authors(author_id)
);
```
7. 存储过程(statistics)
```
DELIMITER //
CREATE PROCEDURE statistics (IN author_id INT)
BEGIN
SELECT * FROM papers WHERE author_id = author_id;
END //
DELIMITER ;
```
8. 触发器(update_review_received)
```
DELIMITER //
CREATE TRIGGER update_review_received AFTER UPDATE ON payment
FOR EACH ROW
BEGIN
IF NEW.review_fee <> OLD.review_fee THEN
UPDATE payment SET review_received = '是' WHERE payment_id = NEW.payment_id;
END IF;
END //
DELIMITER ;
```
这些表结构和约束可以实现所述功能,但具体的实现可能还需要根据实际情况进行调整。
阅读全文