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

29 lines
975 B
SQL
Raw 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 `announcements` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`title` VARCHAR(128) NOT NULL,
`content` TEXT NOT NULL,
`publisher_id` INT NOT NULL,
`is_top` TINYINT DEFAULT 0, -- 是否置顶
`status` TINYINT DEFAULT 1, -- 1有效 0撤回/禁用
`created_at` DATETIME NOT NULL,
`updated_at` DATETIME NOT NULL,
FOREIGN KEY (`publisher_id`) REFERENCES `users`(`id`)
);
-- 用户消息通知表
CREATE TABLE `notifications` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`user_id` INT NOT NULL,
`title` VARCHAR(128) NOT NULL,
`content` TEXT NOT NULL,
`type` VARCHAR(32) NOT NULL, -- 消息类型
`status` TINYINT DEFAULT 0, -- 0未读 1已读
`sender_id` INT, -- 发送人系统消息可为NULL或0
`created_at` DATETIME NOT NULL,
`read_at` DATETIME DEFAULT NULL,
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`),
FOREIGN KEY (`sender_id`) REFERENCES `users`(`id`)
);