Book_system/sql/module3_borrow_record.sql
2025-04-29 11:18:18 +08:00

18 lines
761 B
SQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- 借阅表
CREATE TABLE `borrow_records` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`user_id` INT NOT NULL, -- 借阅人用户id
`book_id` INT NOT NULL, -- 图书id
`borrow_date` DATETIME NOT NULL, -- 借书时间
`due_date` DATETIME NOT NULL, -- 应还日期
`return_date` DATETIME DEFAULT NULL, -- 实际归还(未归还为空)
`renew_count` INT DEFAULT 0, -- 续借次数
`status` TINYINT DEFAULT 1, -- 1:借出 2:已归还 3:逾期未还
`remark` VARCHAR(255), -- 管理备注
`created_at` DATETIME NOT NULL,
`updated_at` DATETIME NOT NULL,
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`),
FOREIGN KEY (`book_id`) REFERENCES `books`(`id`)
);