Modified post page for assignment files.
[Assignment-Trapper.git] / code_db.sql
blob67fdca6288cab0c5e9d434499fd0b46462597bcd
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 trapper;
8 USE trapper;
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(256),                              # comment about this assignment
27         timeposted timestamp NOT NULL,                  # time comment was posted
28         PRIMARY KEY (comment_id)
31 CREATE TABLE schedule (
32         sched_id int NOT NULL AUTO_INCREMENT,
33         class_id int NOT NULL,                          # class section number
34         assign_type int NOT NULL,                       # type of assignment
35         title varchar(256) NOT NULL,                    # title of assignment
36         chapter varchar(256) NOT NULL,                  # chapter number
37         section_id varchar(256) NOT NULL,               # section number
38         ava_date  DATETIME NOT NULL,                    # date for opening of assignment
39         due_date DATETIME NOT NULL,                     # due date for assignment
40         timeposted timestamp NOT NULL,                  # time posting
41         graded int NOT NULL,                            # 0 for no and 1 for yes
42         PRIMARY KEY (sched_id)
45 CREATE TABLE types (
46         assign_type int NOT NULL,
47         type_name varchar(256),
48         PRIMARY KEY (assign_type)
51 INSERT INTO types values (0, "Final Exam");
52 INSERT INTO types values (1, "In-Class Practice Programs");
53 INSERT INTO types values (2, "Homework Programs");
54 INSERT INTO types values (3, "Chapter Test");
55 INSERT INTO types values (4, "Extra Credit");
57 CREATE TABLE class (
58         class_id int NOT NULL,
59         class_name varchar(256) NOT NULL,
60         class_section varchar(256) NOT NULL,
61         class_location varchar(256),
62         class_instructor varchar(256) NOT NULL,
63         PRIMARY KEY (class_id)
66 CREATE TABLE enrollment (
67         enrollment_id int NOT NULL AUTO_INCREMENT,
68         class_id int NOT NULL,
69         user_id int NOT NULL,
70         PRIMARY KEY (enrollment_id)
74 CREATE TABLE sub (
75         sub_id int NOT NULL AUTO_INCREMENT,             # address number - should be KEY to this Table
76         user_id int NOT NULL,                           # user ID
77         sched_id int NOT NULL,                          # schedule ID
78         time_post DATETIME NOT NULL,                    # time posting
79         PRIMARY KEY (sub_id)
83 CREATE TABLE files (
84         file_id int NOT NULL AUTO_INCREMENT,            # file number - should be KEY to this Table
85         sched_id int NOT NULL,                          # submission number
86         user_id int NOT NULL,                           # user ID who submitted file
87         file_1 text,                                    # each file gets one column - not the best way but simple
88         file_name varchar(256),                         # original name of file
89         file_size int,                                  # size of file in bytes
90         time_post DATETIME NOT NULL,                    # time file posted
91         PRIMARY KEY (file_id)
94 CREATE TABLE users (
95         user_id int NOT NULL AUTO_INCREMENT,            #
96         email varchar(128) NOT NULL,                    # 
97         password varchar(128) NOT NULL,                 #
98         name varchar(128) NOT NULL,                     # name of user
99         attempts int NOT NULL,                          # number of bad attempts to login
100         role int NOT NULL,                              # 0 is prof, 1 is student
101         first_login int NOT NULL,                       # 0 is false, 1 is true
102         PRIMARY KEY (user_id)
105 # initial root account with default password
106 insert into users values ("", "steven.schronk@my.tccd.edu", "password", "Schronk, Steven", 0, 0, 1);