Added discussion feature to site.
[Assignment-Trapper.git] / code_db.sql
blob25f07787cbdfe80a982b8f1f7d7f81b45be7d82e
1 # Creates Database for Assignment Trapper
3 # Use this command to run this script:
5 # mysql -u root -p < create_db.sql
7 CREATE DATABASE trapper2;
8 USE trapper2;
10 CREATE TABLE filecom (
11         filecom_id int NOT NULL AUTO_INCREMENT,
12         file_id int NOT NULL,                           # file ID
13         line_no int NOT NULL,                           # line number in file
14         user_id int NOT NULL,                           # user who made the comment
15         txt  varchar(128),                              # comment made about line
16         timeposted timestamp NOT NULL,                  # time comment was posted
17         PRIMARY KEY (filecom_id)
20 CREATE TABLE comments (
21         comment_id int NOT NULL AUTO_INCREMENT,
22         user_id int NOT NULL,                           # user ID - person who commented
23         sub_id int  NOT NULL,                           # submission ID
24         fac_id int,                                     # faculty identification id for faculty comments
25         role int NOT NULL,                              # 0 is prof, 1 is student
26         txt varchar(65536),                             # comment about this assignment
27         timeposted timestamp NOT NULL,                  # time comment was posted
28         PRIMARY KEY (comment_id)
31 CREATE TABLE sched_details (
32         detail_id int NOT NULL AUTO_INCREMENT,
33         sched_id int NOT NULL,
34         user_id int NOT NULL,
35         user_viewed int,                                # comments have been viewed by user
36         fac_viewed int,                                 # comments have been viewed by faculty
37         help_me int,                                    # students can ask for help on thier assignments
38         late int,                                       # students who turn in work late have assignment permanently marked
39         timeposted timestamp NOT NULL,                  # time comment was posted
40         PRIMARY KEY (detail_id)
43 # alter table sched_details add column late int;
45 CREATE TABLE schedule (
46         sched_id int NOT NULL AUTO_INCREMENT,
47         class_id int NOT NULL,                          # class section number
48         assign_type int NOT NULL,                       # type of assignment
49         title varchar(256) NOT NULL,                    # title of assignment
50         chapter varchar(256) NOT NULL,                  # chapter number
51         section_id varchar(256) NOT NULL,               # section number
52         ava_date  DATETIME NOT NULL,                    # date for opening of assignment
53         due_date DATETIME NOT NULL,                     # due date for assignment
54         timeposted timestamp NOT NULL,                  # time posting
55         graded int NOT NULL,                            # 0 for no and 1 for yes
56         PRIMARY KEY (sched_id)
59 CREATE TABLE types (
60         assign_type int NOT NULL,
61         type_name varchar(256),
62         PRIMARY KEY (assign_type)
65 INSERT INTO types values (0, "Final Exam");
66 INSERT INTO types values (1, "In-Class Practice Programs");
67 INSERT INTO types values (2, "Homework Programs");
68 INSERT INTO types values (3, "Chapter Test");
69 INSERT INTO types values (4, "Extra Credit");
71 CREATE TABLE class (
72         class_id int NOT NULL,
73         class_name varchar(256) NOT NULL,
74         class_section varchar(256) NOT NULL,
75         class_location varchar(256),
76         class_instructor varchar(256) NOT NULL,
77         PRIMARY KEY (class_id)
80 insert into class values ("", "Test Class", "101", "RM 205", "Schronk,Steven");
82 CREATE TABLE enrollment (
83         enrollment_id int NOT NULL AUTO_INCREMENT,
84         class_id int NOT NULL,
85         user_id int NOT NULL,
86         PRIMARY KEY (enrollment_id)
89 insert into enrollment values ("", "0", "1");
92 CREATE TABLE sub (
93         sub_id int NOT NULL AUTO_INCREMENT,             # address number - should be KEY to this Table
94         user_id int NOT NULL,                           # user ID
95         sched_id int NOT NULL,                          # schedule ID
96         time_post DATETIME NOT NULL,                    # time posting
97         PRIMARY KEY (sub_id)
101 CREATE TABLE files (
102         file_id int NOT NULL AUTO_INCREMENT,            # file number - should be KEY to this Table
103         sched_id int NOT NULL,                          # submission number
104         user_id int NOT NULL,                           # user ID who submitted file
105         file_1 text,                                    # each file gets one column - not the best way but simple
106         file_name varchar(256),                         # original name of file
107         file_size int,                                  # size of file in bytes
108         time_post DATETIME NOT NULL,                    # time file posted
109         PRIMARY KEY (file_id)
112 CREATE TABLE chat (
113         chat_id int NOT NULL AUTO_INCREMENT,
114         user_id int NOT NULL,
115         content varchar(256) NOT NULL,
116         chat_time timestamp NOT NULL,
117         PRIMARY KEY(chat_id)
120 CREATE TABLE discussion_topic (
121         topic_id int NOT NULL AUTO_INCREMENT,
122         topic_name varchar(128),
123         topic_description varchar(256),
124         discussion_sticky int NOT NULL,                         # 1 if sticky 0 if not
125         topic_time timestamp NOT NULL,
126         PRIMARY KEY(topic_id)
129 insert into discussion_topic values("", "Class Suggestions", "Make suggestions for new classes or complain about what is wrong with the current classes.", "1", NOW());
130 insert into discussion_topic values("", "Site Suggestions", "Conversation about how to make this website better.", "1", NOW());
131 insert into discussion_topic values("", "Technical Support", "Obtaining general technical support about using the site.", "1", NOW());
132 insert into discussion_topic values("", "Talk About Anything", "Talk about whatever you like here.", "0", NOW());
134 CREATE TABLE discussion_post (
135         post_id int NOT NULL AUTO_INCREMENT,
136         user_id int NOT NULL,                                   # no anonymous users
137         topic_id int,                                                   # if no topic set, goes with assignment
138         sched_id int,
139         post_content text,
140         post_time timestamp NOT NULL,
141         PRIMARY KEY(post_id)
144 insert into discussion_post values ("", "1", "1", "", "Please help.", now());
145 insert into discussion_post values ("", "1", "1", "", "Need help with email.", now());
146 insert into discussion_post values ("", "1", "3", "", "Could we have more discussions?", now());
147 insert into discussion_post values ("", "1", "2", "", "Lets tlk about anything here", now());
152 CREATE TABLE news (
153         news_id int NOT NULL AUTO_INCREMENT,
154         user_id int NOT NULL,                                   # no anonymous news
155         news text,
156         news_open DATETIME NOT NULL,                    # news appears for users
157         news_close DATETIME NOT NULL,                   # news no longer on front page for users
158         news_update_time timestamp NOT NULL,    # timestamp for updates
159         PRIMARY KEY(news_id)
162 CREATE TABLE users (
163         user_id int NOT NULL AUTO_INCREMENT,            #
164         email varchar(128) NOT NULL,                    # 
165         password varchar(128) NOT NULL,                 #
166         name varchar(128) NOT NULL,                     # name of user
167         attempts int NOT NULL,                          # number of bad attempts to login
168         role int NOT NULL,                              # 0 is prof, 1 is student
169         first_login int NOT NULL,                       # 0 is false, 1 is true
170         last_click timestamp,                           # for instant message user list
171         reset_hash varchar(40),                         # used to reset a user password via email
172         PRIMARY KEY (user_id)
175 # initial root account with default password
176 insert into users values ("", "steven.schronk@my.tccd.edu", sha1("password"), "Schronk, Steven", 0, 0, 1,NOW(),"");