文章目录
建立文章表和借书表
CREATE TABLE authors (
uid INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
username VARCHAR(45) NOT NULL UNIQUE
);
CREATE TABLE articles(
aid INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
uid INT NOT NULL,
title VARCHAR(200) NOT NULL,
body TEXT NOT NULL,
published_at DATETIME NOT NULL
);
CREATE TABLE books(
bid INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
name VARCHAR(20) NOT NULL,
total_count INT NOT NULL,
current_count INT NOT NULL
);
CREATE TABLE users(
uid INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
username VARCHAR(45) NOT NULL UNIQUE
);
CREATE TABLE borrow_records(
brid INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
uid INT NOT NULL COMMENT '谁的书',
bid INT NOT NULL COMMENT '借了什么书',
borrowed_at DATETIME NOT NULL COMMENT '何时借的书'
);
|