-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMIT_create_table.sql
95 lines (87 loc) · 1.71 KB
/
MIT_create_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
IF DB_ID('MIT') IS NULL
BEGIN
CREATE DATABASE MIT
END
GO
USE MIT
GO
IF OBJECT_ID('dbo.Team') IS NULL
BEGIN
CREATE TABLE [Team](
[Id] int PRIMARY KEY,
[TeamName] char(50),
[Point] int,
[Status] tinyint default 1
)
END
GO
IF OBJECT_ID('dbo.Round') IS NULL
BEGIN
CREATE TABLE [Round](
[Id] int PRIMARY KEY,
[RoundName] char(50),
[Quantity] int,
[Maxpoint] int,
[Status] tinyint default 1
)
END
GO
IF OBJECT_ID('dbo.Question') IS NULL
BEGIN
CREATE TABLE [Question](
[Id] int PRIMARY KEY,
[RoundId] int REFERENCES [Round]([Id]),
[ImageUri] nvarchar(max) default null,
[Point] int,
[Solution] nvarchar(max),
[MaxPoint] int,
[Status] tinyint default 1
)
END
GO
IF OBJECT_ID('dbo.Testcase') IS NULL
BEGIN
CREATE TABLE [Testcase](
[Id] int PRIMARY KEY,
[QuestionId] int REFERENCES [Question]([Id]),
[Input] nvarchar(max) null,
[Output] nvarchar(max) null,
[Point] int,
[Status] tinyint default 1
)
END
GO
IF OBJECT_ID('dbo.Answer') IS NULL
BEGIN
CREATE TABLE [Answer](
[Id] int PRIMARY KEY,
[Team] int REFERENCES [Team]([Id]),
[QuestionId] int REFERENCES [Question]([Id]),
[Answer] nvarchar(max),
[Time] time,
[Point] int,
[Status] tinyint default 0
)
END
GO
IF OBJECT_ID('dbo.Shape') IS NULL
BEGIN
CREATE TABLE [Shape](
[Id] int PRIMARY KEY,
[Question] int REFERENCES [Question]([Id]),
[Type] int,
[Text] nvarchar(max),
[Status] tinyint default 1
)
END
GO
IF OBJECT_ID('dbo.AnswerTest') IS NULL
BEGIN
CREATE TABLE [AnswerTest](
[TestCaseId] int REFERENCES [TestCase]([Id]),
[AnswerId] int REFERENCES [Answer]([Id]),
[Status] tinyint default 0
PRIMARY KEY ([TestCaseId], [AnswerId])
)
END
GO