/*
 Navicat MySQL Dump SQL

 Source Server         : test
 Source Server Type    : MySQL
 Source Server Version : 90100 (9.1.0)
 Source Host           : localhost:3306
 Source Schema         : test

 Target Server Type    : MySQL
 Target Server Version : 90100 (9.1.0)
 File Encoding         : 65001

 Date: 23/12/2024 05:02:32
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for posts
-- ----------------------------
DROP TABLE IF EXISTS `posts`;
CREATE TABLE `posts`  (
  `PostID` int NOT NULL AUTO_INCREMENT,
  `Title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `Content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `PublishTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `AuthorID` int NOT NULL,
  `ReviewStatus` enum('approved','pending','rejected') CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'pending',
  `IsRecommended` tinyint(1) NOT NULL DEFAULT 0,
  PRIMARY KEY (`PostID`) USING BTREE,
  INDEX `AuthorID`(`AuthorID` ASC) USING BTREE,
  CONSTRAINT `posts_ibfk_1` FOREIGN KEY (`AuthorID`) REFERENCES `users` (`UserID`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of posts
-- ----------------------------
INSERT INTO `posts` VALUES (1, '第一篇文章', '这是管理员发布的第一篇文章内容...', '2024-12-23 04:46:27', 1, 'approved', 1);
INSERT INTO `posts` VALUES (2, '第二篇文章', '这是普通用户发布的一篇文章内容...', '2024-12-23 04:46:27', 2, 'pending', 0);

-- ----------------------------
-- Table structure for user_security_questions_answers
-- ----------------------------
DROP TABLE IF EXISTS `user_security_questions_answers`;
CREATE TABLE `user_security_questions_answers`  (
  `RecordID` int NOT NULL AUTO_INCREMENT,
  `UserID` int NOT NULL,
  `QuestionNumber` tinyint NOT NULL,
  `QuestionContent` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `AnswerHash` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  PRIMARY KEY (`RecordID`) USING BTREE,
  UNIQUE INDEX `UserID`(`UserID` ASC, `QuestionNumber` ASC) USING BTREE,
  CONSTRAINT `user_security_questions_answers_ibfk_1` FOREIGN KEY (`UserID`) REFERENCES `users` (`UserID`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `user_security_questions_answers_chk_1` CHECK (`QuestionNumber` in (1,2))
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of user_security_questions_answers
-- ----------------------------
INSERT INTO `user_security_questions_answers` VALUES (1, 1, 1, '您的第一个宠物的名字是什么？', 'cd6357efdd966de8c0cb2f876cc89ec74ce35f0968e11743987084bd42fb8944');
INSERT INTO `user_security_questions_answers` VALUES (2, 1, 2, '您小时候最好的朋友叫什么名字？', '78675cc176081372c43abab3ea9fb70c74381eb02dc6e93fb6d44d161da6eeb3');
INSERT INTO `user_security_questions_answers` VALUES (3, 2, 1, '您的小学名字是什么？', 'd64debd942d7dc26a851231583b1721f43ea936fa41932b6dad7556e5f8cd24a');
INSERT INTO `user_security_questions_answers` VALUES (4, 2, 2, '您最喜欢的书是什么？', '92719fe0cf8cd51592af31ee8a5736d79f7273777fa3f7b70bfe993a4cd32180');

-- ----------------------------
-- Table structure for users
-- ----------------------------
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users`  (
  `UserID` int NOT NULL AUTO_INCREMENT,
  `Username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `PhoneNumber` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `PasswordHash` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `JoinDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `UserType` enum('user','admin') CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'user',
  `Birthday` date NULL DEFAULT NULL,
  `Signature` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL,
  PRIMARY KEY (`UserID`) USING BTREE,
  UNIQUE INDEX `Username`(`Username` ASC) USING BTREE,
  UNIQUE INDEX `PhoneNumber`(`PhoneNumber` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of users
-- ----------------------------
INSERT INTO `users` VALUES (1, 'admin_user', '13800138000', '8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92', '2024-12-23 04:46:27', 'admin', '1990-01-01', '我是管理员');
INSERT INTO `users` VALUES (2, 'regular_user', '13800138001', '8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92', '2024-12-23 04:46:27', 'user', '1995-07-15', '热爱编程的普通人');

SET FOREIGN_KEY_CHECKS = 1;
