-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtable.sql
118 lines (95 loc) · 2.51 KB
/
table.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+08:00";
-- 上面的时区设置为东八区时间,以便查看。请根据实际需求修改。
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
-- --------------------------------------------------------
--
-- 表的结构 `questions`
--
CREATE TABLE `questions` (
`id` int NOT NULL,
`question_text` text NOT NULL,
`option_a` varchar(255) NOT NULL,
`option_b` varchar(255) NOT NULL,
`option_c` varchar(255) NOT NULL,
`option_d` varchar(255) NOT NULL,
`answer` varchar(255) NOT NULL,
`type` enum('single','multiple') NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
-- --------------------------------------------------------
--
-- 表的结构 `results`
--
CREATE TABLE `results` (
`id` int NOT NULL,
`user_id` int NOT NULL,
`score` int NOT NULL,
`end_time` timestamp NOT NULL,
`invitation_code` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
-- --------------------------------------------------------
--
-- 表的结构 `users`
--
CREATE TABLE `users` (
`id` int NOT NULL,
`username` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`start_time` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
--
-- 转储表的索引
--
--
-- 表的索引 `questions`
--
ALTER TABLE `questions`
ADD PRIMARY KEY (`id`);
--
-- 表的索引 `results`
--
ALTER TABLE `results`
ADD PRIMARY KEY (`id`),
ADD KEY `user_id` (`user_id`);
--
-- 表的索引 `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`);
--
-- 在导出的表使用AUTO_INCREMENT
--
--
-- 使用表AUTO_INCREMENT `questions`
--
ALTER TABLE `questions`
MODIFY `id` int NOT NULL AUTO_INCREMENT;
--
-- 使用表AUTO_INCREMENT `results`
--
ALTER TABLE `results`
MODIFY `id` int NOT NULL AUTO_INCREMENT;
--
-- 使用表AUTO_INCREMENT `users`
--
ALTER TABLE `users`
MODIFY `id` int NOT NULL AUTO_INCREMENT;
--
-- 限制导出的表
--
--
-- 限制表 `results`
--
ALTER TABLE `results`
ADD CONSTRAINT `results_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`);
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;