forked from znorcross211/Project_418
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOurDatabaseTables.sql
More file actions
78 lines (70 loc) · 2.09 KB
/
Copy pathOurDatabaseTables.sql
File metadata and controls
78 lines (70 loc) · 2.09 KB
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
CREATE TABLE UserProfile(
UserProfileId int AUTO_INCREMENT,
Name varchar(20) NOT NULL,
Password varchar(30) NOT NULL,
isAdmin tinyint NOT NULL,
PRIMARY KEY (UserProfileId)
);
CREATE TABLE ChangeColor(
ChangeColorId int NOT NULL,
UserProfileId int NOT NULL,
Color varchar(50) NOT NULL,
PRIMARY KEY (ChangeColorId),
FOREIGN KEY (UserProfileid) REFERENCES UserProfile(UserProfileId)
);
CREATE TABLE Test(
TestId int AUTO_INCREMENT,
TestTitle varchar(50),
PRIMARY KEY (TestId)
);
CREATE TABLE TestStatus(
TestStatusId int AUTO_INCREMENT,
TestId int NOT NULL,
UserProfileId int NOT NULL,
TestStatus tinyint NOT NULL,
Grade DECIMAL(5,2) NOT NULL,
PRIMARY KEY (TeststatusId),
FOREIGN KEY (TestId) REFERENCES Test(TestId),
FOREIGN KEY (UserProfileId) REFERENCES UserProfile(UserProfileId)
);
CREATE TABLE Question(
QuestionId int AUTO_INCREMENT,
TypeOfQuestion varchar(20) NOT NULL,
Answer varchar(100) NOT NULL,
Question varchar(500) NOT NULL,
Category varchar(20),
PRIMARY KEY (QuestionId)
);
CREATE TABLE QuestionsForTest(
QuestionsForTestId int AUTO_INCREMENT,
QuestionId int NOT NULL,
TestId int NOT NULL,
PRIMARY KEY (QuestionsForTestId),
FOREIGN KEY (QuestionId) REFERENCES Question(QuestionId),
FOREIGN KEY (TestId) REFERENCES Test(TestId)
);
CREATE TABLE Image(
ImageId int AUTO_INCREMENT,
QuestionId int NOT NULL,
Image BLOB NOT NULL,
PRIMARY KEY (ImageId),
FOREIGN KEY (QuestionId) REFERENCES Question(QuestionId)
);
CREATE TABLE Choices(
ChoicesId int AUTO_INCREMENT,
QuestionId int NOT NULL,
PossibleAnswer varchar(400) NOT NULL,
PRIMARY KEY (ChoicesId),
FOREIGN KEY (QuestionId) REFERENCES Question(QuestionId)
);
CREATE TABLE UserAnswers(
UserAnswerId int AUTO_INCREMENT,
UserProfileId int NOT NULL,
TestId int NOT NULL,
QuestionId int NOT NULL,
UserAnswer varchar(400) NOT NULL,
PRIMARY KEY (UserAnswerId),
FOREIGN KEY (UserProfileId) REFERENCES UserProfile(UserProfileId),
FOREIGN KEY (TestId) REFERENCES Test(TestId),
FOREIGN KEY (QuestionId) REFERENCES Question(QuestionId)
);