initial commit

This commit is contained in:
SowinskiBraeden committed 2025-11-28 16:27:38 -08:00
commit 9b8a13f429
17 files changed
+1277

No files matched your search

+48
View File
@@ -0,0 +1,48 @@
-- 1.
SELECT le_section_id, lab_set_code, course_code, la_title, lab_day_of_week
FROM lab_event
INNER JOIN lab_section
ON lab_section.lab_section_id = lab_event.le_section_id
INNER JOIN lab_assignment
ON lab_assignment.la_lab_number = lab_event.le_number
WHERE term_code = '202530';
-- 2.
SELECT pgr_student_id, COUNT(*) AS labs_attended
FROM progress
GROUP BY pgr_student_id;
-- 3.
SELECT pgr_student_id, student_set_code, lab_section_id, COUNT(*) FILTER (WHERE pgr_late 1= 'f') AS late_submissions
FROM progress
INNER JOIN student
ON student.student_id = progress.pgr_student_id
INNER JOIN lab_section
ON student.student_set_code = lab_section.lab_set_code
GROUP BY pgr_student_id, student_set_code, lab_section_id;
-- 4.
SELECT student_set_code, TO_CHAR(AVG(pgr_instructor_assessment::numeric), 'FM999999.00') AS section_average
FROM progress
INNER JOIN student
ON student.student_id = progress.pgr_student_id
GROUP BY student_set_code
ORDER BY student_set_code;
-- 5.
SELECT student_first_name || ' ' || student_last_name AS student_name, student_set_code, le_number
FROM student
INNER JOIN progress
ON progress.pgr_student_id = student.student_id
INNER JOIN lab_event
ON lab_event.le_id = progress.pgr_event_id
WHERE pgr_instructor_assessment IS NULL OR pgr_self_assessment IS NULL;
-- 6.
SELECT student_id, student_first_name || ' ' || student_last_name AS student_name, student_set_code, TO_CHAR(AVG(pgr_instructor_assessment::numeric), 'FM999999.00') AS student_average
FROM student
JOIN progress
ON student.student_id = progress.pgr_student_id
GROUP BY student_id, student_first_name, student_last_name, student_set_code
HAVING AVG(pgr_instructor_assessment::numeric) >= 4.5
ORDER BY student_id;
+56
View File
@@ -0,0 +1,56 @@
CREATE OR REPLACE VIEW ta_view AS
SELECT
ls.lab_section_id AS lab_section,
e.le_id,
s.student_id,
s.student_first_name || ' ' ||
s.student_last_name AS full_name,
p.pgr_attendance,
p.pgr_inlab_submission_link,
p.pgr_instructor_assessment
FROM progress p
JOIN student s
ON p.pgr_student_id = s.student_id
JOIN lab_event e
ON p.pgr_event_id = e.le_id
JOIN lab_section ls
ON e.le_section_id = ls.lab_section_id;
CREATE OR REPLACE VIEW v_section_overview AS
SELECT
t.term_code,
ss.set_code AS set_name,
c.course_code,
ls.lab_section_id AS section_id,
COUNT(DISTINCT le.le_id) AS total_events,
AVG(CAST(p.pgr_instructor_assessment AS NUMERIC)) AS avg_instructor_assessment
FROM lab_section AS ls
JOIN course AS c ON c.course_code = ls.lab_course_code
JOIN term AS t ON t.term_code = ls.lab_term_code
JOIN student_set AS ss ON ss.set_code = ls.lab_set_code
LEFT JOIN lab_event AS le
ON le.le_section_id = ls.lab_section_id
AND le.course_code = ls.lab_course_code
AND le.term_code = ls.lab_term_code
LEFT JOIN progress AS p
ON p.pgr_event_id = le.le_id
GROUP BY
t.term_code,
ss.set_code,
c.course_code,
ls.lab_section_id;
--everything from section
SELECT *
FROM v_section_overview
ORDER BY term_code, set_name, course_code, section_id;
-- only sections that actually have events
SELECT *
FROM v_section_overview
WHERE total_events > 0
ORDER BY total_events DESC;
--This is the view for ta
SELECT *
FROM ta_view;
+11
View File
@@ -0,0 +1,11 @@
-- 1. Create a role for TAs
CREATE ROLE ta_role;
-- 2. Allow this role to view your TA-related views
GRANT SELECT ON v_ta_progress_summary, v_section_overview TO ta_role;
-- 3. Create a demo user (only works if your server allows user creation)
CREATE USER ta_demo WITH PASSWORD 'ta_demo123';
-- 4. Give the demo user the TA role
GRANT ta_role TO ta_demo;
+44
View File
@@ -0,0 +1,44 @@
Primary Keys
For our design, we decided to go with natural primary keys for all tables because the data we were given in the CSVs already included unique identifiers that made sense in the real world.
We didnt see a reason to generate artificial IDs since each table had something that was already unique and meaningful.
Natural PKs we used:
course_code e.g. COMP1510
term_code e.g. 202530
student_set e.g. SETD
student uses student_id (like A001)
lab_section uses lab_section_id (like L01)
lab_assignment uses la_assignment_id (like LAB01)
lab_event uses le_id (like L01-L01)
user_account, progress, and progress_change_log also use text-based IDs that are unique.
Foreign Keys & Relationships
We made sure every relationship matched the business rules:
Students must belong to a Set, and the student_set_code cant be null.
If a set code changes, it cascades to all students (ON UPDATE CASCADE).
Lab Sections link to a Course, Term, and Set. All of those are required and set to cascade on update too.
Lab Events belong to a Lab Section, and we used a composite foreign key (le_section_id, course_code, term_code) to make sure the event always matches the correct section, course, and term. We also added ON DELETE CASCADE so deleting a section deletes its events automatically.
Student_Section connects students to lab sections, and if a section gets deleted, the link goes with it.
Progress connects a student to a lab event. Deleting an event now also deletes any related progress (we used ON DELETE CASCADE for that).
Progress Change Log connects to both progress and user_account. Deleting a progress record removes its log, but deleting a user is blocked to protect the audit trail.
Uniqueness & Constraints
Student emails must be unique (no duplicate addresses).
Each combination of (lab_section_id, lab_course_code, lab_term_code) is unique to prevent mix-ups between sections.
Term codes must follow the six-digit format (CHECK (term_code ~ '^[0-9]{6}$')).
Course credits must be between 1 and 9.
lab_event checks that le_ends_at is after le_starts_at.
progress checks that pgr_polished_submitted_at is after pgr_inlab_submitted_at when both are present.
Boolean fields like pgr_prepared and pgr_late default to FALSE.
Cascading Logic
We used cascading only when it made logical sense:
Deleting a lab_section removes its lab_events, which also removes any related progress and change logs automatically.
For tables like user_account, we kept delete restricted so we dont lose audit history.
Naming Conventions
We used prefixes to make joins easier and keep things organized.
For example:
le_ for lab_event columns,
pgr_ for progress,
chl_ for progress_change_log.
Also, every constraint is named properly (pk_, fk_, ck_, uq_) so if theres an error, its obvious where it came from.
+168
View File
@@ -0,0 +1,168 @@
DROP SCHEMA IF EXISTS lab_tracker_group_22 CASCADE;
CREATE SCHEMA lab_tracker_group_22;
SET search_path TO lab_tracker_group_22;
DROP TABLE IF EXISTS progress_change_log;
DROP TABLE IF EXISTS progress;
DROP TABLE IF EXISTS lab_event;
DROP TABLE IF EXISTS lab_assignment;
DROP TABLE IF EXISTS student_section;
DROP TABLE IF EXISTS lab_section;
DROP TABLE IF EXISTS student;
DROP TABLE IF EXISTS user_account;
DROP TABLE IF EXISTS student_set;
DROP TABLE IF EXISTS term;
DROP TABLE IF EXISTS course;
CREATE TABLE course (
course_code VARCHAR(20) CONSTRAINT pk_course PRIMARY KEY,
course_title VARCHAR(200),
credits NUMERIC(3,0)
CONSTRAINT ck_course_credits CHECK (credits BETWEEN 1 AND 9)
);
CREATE TABLE term (
term_code VARCHAR(10) CONSTRAINT pk_term PRIMARY KEY,
term_name VARCHAR(50),
term_start_date DATE,
term_end_date DATE,
CONSTRAINT ck_term_code_fmt CHECK (term_code ~ '^[0-9]{6}$')
);
CREATE TABLE student_set (
set_code VARCHAR(10) CONSTRAINT pk_student_set PRIMARY KEY,
set_campus VARCHAR(50)
);
CREATE TABLE user_account (
user_id VARCHAR(50) CONSTRAINT pk_user_account PRIMARY KEY,
user_full_name VARCHAR(120) NOT NULL,
user_role VARCHAR(30),
user_email VARCHAR(120) CONSTRAINT uq_user_email UNIQUE
);
CREATE TABLE student (
student_id VARCHAR(30) CONSTRAINT pk_student PRIMARY KEY,
student_set_code VARCHAR(10) NOT NULL,
student_first_name VARCHAR(80) NOT NULL,
student_last_name VARCHAR(80) NOT NULL,
student_email VARCHAR(120),
CONSTRAINT uq_student_email UNIQUE (student_email),
CONSTRAINT fk_student_set
FOREIGN KEY (student_set_code)
REFERENCES student_set(set_code)
ON UPDATE CASCADE
);
CREATE TABLE lab_section (
lab_section_id VARCHAR(20) CONSTRAINT pk_lab_section PRIMARY KEY,
lab_course_code VARCHAR(20) NOT NULL,
lab_term_code VARCHAR(10) NOT NULL,
lab_set_code VARCHAR(10) NOT NULL,
lab_section_type VARCHAR(10),
lab_day_of_week VARCHAR(10),
lab_start_time TIME,
lab_end_time TIME,
lab_location VARCHAR(100),
CONSTRAINT fk_lab_section_course FOREIGN KEY (lab_course_code)
REFERENCES course(course_code) ON UPDATE CASCADE,
CONSTRAINT fk_lab_section_term FOREIGN KEY (lab_term_code)
REFERENCES term(term_code) ON UPDATE CASCADE,
CONSTRAINT fk_lab_section_set FOREIGN KEY (lab_set_code)
REFERENCES student_set(set_code) ON UPDATE CASCADE,
CONSTRAINT uq_lab_section_triplet
UNIQUE (lab_section_id, lab_course_code, lab_term_code)
);
CREATE TABLE student_section (
ss_section_id VARCHAR(20) NOT NULL,
ss_student_id VARCHAR(30) NOT NULL,
CONSTRAINT pk_student_section PRIMARY KEY (ss_section_id, ss_student_id),
CONSTRAINT fk_student_section_section FOREIGN KEY (ss_section_id)
REFERENCES lab_section(lab_section_id) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT fk_student_section_student FOREIGN KEY (ss_student_id)
REFERENCES student(student_id) ON UPDATE CASCADE
);
CREATE TABLE lab_assignment (
la_assignment_id VARCHAR(20) CONSTRAINT pk_lab_assignment PRIMARY KEY, la_course_code VARCHAR(20) NOT NULL,
la_term_code VARCHAR(10),
la_lab_number INTEGER,
la_title VARCHAR(200),
CONSTRAINT fk_assignment_course FOREIGN KEY (la_course_code)
REFERENCES course(course_code) ON UPDATE CASCADE,
CONSTRAINT fk_assignment_term FOREIGN KEY (la_term_code)
REFERENCES term(term_code) ON UPDATE CASCADE
);
CREATE TABLE lab_event (
le_id VARCHAR(32) CONSTRAINT pk_lab_event PRIMARY KEY,
le_section_id VARCHAR(20) NOT NULL,
course_code VARCHAR(20) NOT NULL,
term_code VARCHAR(10) NOT NULL,
le_number INTEGER NOT NULL,
le_starts_at TIMESTAMP NOT NULL,
le_ends_at TIMESTAMP NOT NULL,
le_due_at TIMESTAMP,
le_location VARCHAR(100),
CONSTRAINT fk_event_section_triplet
FOREIGN KEY (le_section_id, course_code, term_code)
REFERENCES lab_section (lab_section_id, lab_course_code, lab_term_code)
ON UPDATE CASCADE
ON DELETE CASCADE,
CONSTRAINT ck_event_time_order CHECK (le_ends_at > le_starts_at)
);
CREATE TABLE progress (
pgr_id VARCHAR(50) CONSTRAINT pk_progress PRIMARY KEY,
pgr_student_id VARCHAR(30) NOT NULL,
pgr_event_id VARCHAR(32) NOT NULL,
pgr_lab_number INTEGER,
pgr_status VARCHAR(50),
pgr_prepared BOOLEAN NOT NULL DEFAULT FALSE,
pgr_attendance VARCHAR(20),
pgr_inlab_submitted_at TIMESTAMP,
pgr_inlab_submission_link TEXT,
pgr_polished_submitted_at TIMESTAMP,
pgr_polished_submission_link TEXT,
pgr_instructor_assessment TEXT,
pgr_self_assessment TEXT,
pgr_late BOOLEAN NOT NULL DEFAULT FALSE,
CONSTRAINT fk_prog_student
FOREIGN KEY (pgr_student_id)
REFERENCES student(student_id)
ON UPDATE CASCADE,
CONSTRAINT fk_prog_event
FOREIGN KEY (pgr_event_id)
REFERENCES lab_event(le_id)
ON UPDATE CASCADE
ON DELETE CASCADE,
CONSTRAINT ck_prog_time_order CHECK (
pgr_polished_submitted_at IS NULL
OR pgr_inlab_submitted_at IS NULL
OR pgr_polished_submitted_at >= pgr_inlab_submitted_at
)
);
CREATE TABLE progress_change_log (
chl_change_id VARCHAR(20) CONSTRAINT pk_progress_change_log PRIMARY KEY,
chl_progress_id VARCHAR(50) NOT NULL,
chl_changed_by VARCHAR(50) NOT NULL,
chl_changed_at TIMESTAMP NOT NULL,
chl_field VARCHAR(100) NOT NULL,
chl_old_value VARCHAR(255),
chl_new_value VARCHAR(255),
chl_reason TEXT,
CONSTRAINT fk_chglog_progress FOREIGN KEY (chl_progress_id)
REFERENCES progress(pgr_id) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT fk_chglog_user FOREIGN KEY (chl_changed_by)
REFERENCES user_account(user_id) ON UPDATE CASCADE
);
+186
View File
@@ -0,0 +1,186 @@
-- Clean DB before inserting
TRUNCATE TABLE progress_change_log CASCADE;
TRUNCATE TABLE progress CASCADE;
TRUNCATE TABLE lab_event CASCADE;
TRUNCATE TABLE lab_assignment CASCADE;
TRUNCATE TABLE student_section CASCADE;
TRUNCATE TABLE lab_section CASCADE;
TRUNCATE TABLE student CASCADE;
TRUNCATE TABLE user_account CASCADE;
TRUNCATE TABLE student_set CASCADE;
TRUNCATE TABLE term CASCADE;
TRUNCATE TABLE course CASCADE;
-- Insert courses
INSERT INTO course
(course_code, course_title, credits)
VALUES
('COMP2714', 'Relational Database Systems', 3);
-- Insert terms
INSERT INTO term
(term_code, term_name, term_start_date, term_end_date)
VALUES
('202510', 'Winter 2025', '2025-01-06', '2025-04-11'),
('202520', 'Spring/Summer 2025', '2025-04-28', '2025-08-08'),
('202530', 'Fall 2025', '2025-09-02', '2025-12-12');
-- Insert student sets
INSERT INTO student_set
(set_code, set_campus)
VALUES
('A', 'Burnaby'),
('B', 'Burnaby'),
('C', 'Burnaby'),
('D', 'Burnaby'),
('E', 'Downtown'),
('F', 'Downtown');
-- Insert users
INSERT INTO user_account
(user_id, user_full_name, user_role, user_email)
VALUES
('u_instructor', 'Maryam Khezrzadeh', 'instructor', 'mkhezrzadeh@bcit.ca'),
('u_ta1', 'Daniel Saavedra', 'ta', 'dsaavedra@bcit.ca'),
('u_system', 'Lab Tracker System', 'system', 'noreply@labtracker.local');
-- Insert students
INSERT INTO student
(student_id, student_set_code, student_first_name, student_last_name, student_email)
VALUES
('A001', 'A', 'Ava', 'Nguyen', 'ava.nguyen@my.bcit.ca'),
('A002', 'A', 'Noah', 'Kim', 'noah.kim@my.bcit.ca'),
('A003', 'A', 'Oliver', 'Singh', 'oliver.singh@my.bcit.ca'),
('B001', 'B', 'Maya', 'Fischer', 'maya.fischer@my.bcit.ca'),
('B002', 'B', 'Leo', 'Park', 'leo.park@my.bcit.ca'),
('B003', 'B', 'Zoé', 'Martin', 'zoe.martin@my.bcit.ca'),
('C001', 'C', 'Sofia', 'Chen', 'sofia.chen@my.bcit.ca'),
('C002', 'C', 'Arjun', 'Patel', 'arjun.patel@my.bcit.ca'),
('C003', 'C', 'Liam', 'OReilly', 'liam.oreilly@my.bcit.ca'),
('D001', 'D', 'Layla', 'Haddad', 'layla.haddad@my.bcit.ca'),
('D002', 'D', 'Ethan', 'Wong', 'ethan.wong@my.bcit.ca'),
('D003', 'D', 'Nora', 'Iverson', 'nora.iverson@my.bcit.ca'),
('E001', 'E', 'Diego', 'Alvarez', 'diego.alvarez@my.bcit.ca'),
('E002', 'E', 'Hana', 'Yamamoto', 'hana.yamamoto@my.bcit.ca'),
('E003', 'E', 'Farah', 'Rahimi', 'farah.rahimi@my.bcit.ca'),
('F001', 'F', 'Marco', 'Russo', 'marco.russo@my.bcit.ca'),
('F002', 'F', 'Amir', 'Kazemi', 'amir.kazemi@my.bcit.ca'),
('F003', 'F', 'Chloe', 'Dubois', 'chloe.dubois@my.bcit.ca');
-- Insert lab sections
INSERT INTO lab_section
(lab_section_id, lab_course_code, lab_term_code, lab_set_code, lab_section_type, lab_day_of_week, lab_start_time, lab_end_time, lab_location)
VALUES
('L01', 'COMP2714', '202530', 'A', 'LAB', 'Mon', '09:30', '11:20', 'BBY-SW01-3460'),
('L02', 'COMP2714', '202530', 'B', 'LAB', 'Mon', '13:30', '15:20', 'BBY-SW01-3465'),
('L03', 'COMP2714', '202530', 'C', 'LAB', 'Tue', '18:30', '20:20', 'BBY-SW03-2605'),
('L04', 'COMP2714', '202530', 'D', 'LAB', 'Wed', '09:30', '11:20', 'BBY-SE12-101'),
('L05', 'COMP2714', '202530', 'E', 'LAB', 'Wed', '13:30', '15:20', 'DTC-310'),
('L06', 'COMP2714', '202530', 'F', 'LAB', 'Thu', '18:30', '20:20', 'DTC-318');
-- Insert lab assignments
INSERT INTO lab_assignment
(la_assignment_id, la_course_code, la_term_code, la_lab_number, la_title)
VALUES
('LAB01', 'COMP2714', '202530', 1, 'Environment Setup & Intro SQL'),
('LAB02', 'COMP2714', '202530', 2, 'Conceptual → Logical Mapping'),
('LAB03', 'COMP2714', '202530', 3, 'Logical ERD & Constraints'),
('LAB04', 'COMP2714', '202530', 4, 'Normalization to 3NF'),
('LAB05', 'COMP2714', '202530', 5, 'DDL Implementation'),
('LAB06', 'COMP2714', '202530', 6, 'DML: INSERT/UPDATE/DELETE'),
('LAB07', 'COMP2714', '202530', 7, 'SELECT & JOIN Practice'),
('LAB08', 'COMP2714', '202530', 8, 'Views & Indexes');
-- Insert student enrollments by set → section
INSERT INTO student_section (ss_section_id, ss_student_id) VALUES
('L01', 'A001'),
('L01', 'A002'),
('L01', 'A003'),
('L02', 'B001'),
('L02', 'B002'),
('L02', 'B003'),
('L03', 'C001'),
('L03', 'C002'),
('L03', 'C003'),
('L04', 'D001'),
('L04', 'D002'),
('L04', 'D003'),
('L05', 'E001'),
('L05', 'E002'),
('L05', 'E003'),
('L06', 'F001'),
('L06', 'F002'),
('L06', 'F003');
-- Insert lab events
INSERT INTO lab_event
(le_id, le_section_id, course_code, term_code, le_number, le_starts_at, le_ends_at, le_due_at, le_location)
VALUES
('L01-L01', 'L01', 'COMP2714', '202530', 1, '2025-09-08 09:30', '2025-09-08 11:20', '2025-09-14 23:59', 'BBY-SW01-3460'),
('L01-L02', 'L01', 'COMP2714', '202530', 2, '2025-09-15 09:30', '2025-09-15 11:20', '2025-09-21 23:59', 'BBY-SW01-3460'),
('L01-L03', 'L01', 'COMP2714', '202530', 3, '2025-09-22 09:30', '2025-09-22 11:20', '2025-09-28 23:59', 'BBY-SW01-3460'),
('L02-L01', 'L02', 'COMP2714', '202530', 1, '2025-09-08 13:30', '2025-09-08 15:20', '2025-09-14 23:59', 'BBY-SW01-3465'),
('L02-L02', 'L02', 'COMP2714', '202530', 2, '2025-09-15 13:30', '2025-09-15 15:20', '2025-09-21 23:59', 'BBY-SW01-3465'),
('L02-L03', 'L02', 'COMP2714', '202530', 3, '2025-09-22 13:30', '2025-09-22 15:20', '2025-09-28 23:59', 'BBY-SW01-3465'),
('L03-L01', 'L03', 'COMP2714', '202530', 1, '2025-09-09 18:30', '2025-09-09 20:20', '2025-09-14 23:59', 'BBY-SW03-2605'),
('L03-L02', 'L03', 'COMP2714', '202530', 2, '2025-09-16 18:30', '2025-09-16 20:20', '2025-09-21 23:59', 'BBY-SW03-2605'),
('L03-L03', 'L03', 'COMP2714', '202530', 3, '2025-09-23 18:30', '2025-09-23 20:20', '2025-09-28 23:59', 'BBY-SW03-2605'),
('L04-L01', 'L04', 'COMP2714', '202530', 1, '2025-09-10 09:30', '2025-09-10 11:20', '2025-09-14 23:59', 'BBY-SE12-101'),
('L04-L02', 'L04', 'COMP2714', '202530', 2, '2025-09-17 09:30', '2025-09-17 11:20', '2025-09-21 23:59', 'BBY-SE12-101'),
('L04-L03', 'L04', 'COMP2714', '202530', 3, '2025-09-24 09:30', '2025-09-24 11:20', '2025-09-28 23:59', 'BBY-SE12-101'),
('L05-L01', 'L05', 'COMP2714', '202530', 1, '2025-09-10 13:30', '2025-09-10 15:20', '2025-09-15 09:00', 'DTC-310'),
('L05-L02', 'L05', 'COMP2714', '202530', 2, '2025-09-17 13:30', '2025-09-17 15:20', '2025-09-22 09:00', 'DTC-310'),
('L05-L03', 'L05', 'COMP2714', '202530', 3, '2025-09-24 13:30', '2025-09-24 15:20', '2025-09-29 09:00', 'DTC-310'),
('L06-L01', 'L06', 'COMP2714', '202530', 1, '2025-09-11 18:30', '2025-09-11 20:20', '2025-09-15 09:00', 'DTC-318'),
('L06-L02', 'L06', 'COMP2714', '202530', 2, '2025-09-18 18:30', '2025-09-18 20:20', '2025-09-22 09:00', 'DTC-318'),
('L06-L03', 'L06', 'COMP2714', '202530', 3, '2025-09-25 18:30', '2025-09-25 20:20', '2025-09-29 09:00', 'DTC-318');
-- Insert progress
INSERT INTO progress
(pgr_id, pgr_student_id, pgr_event_id, pgr_lab_number, pgr_status, pgr_prepared, pgr_attendance, pgr_inlab_submitted_at, pgr_inlab_submission_link, pgr_polished_submitted_at, pgr_polished_submission_link, pgr_instructor_assessment, pgr_self_assessment, pgr_late)
VALUES
('A001-L01-L01','A001', 'L01-L01',1, 'Submitted', 'TRUE', 'Present', '2025-09-08 10:45', 'https://submit.bcit.ca/comp2714/inlab/A001-L01-L01.pdf', '2025-09-09 12:45', 'https://submit.bcit.ca/comp2714/polished/A001-L01-L01.pdf', '8.5', '8.2', 'FALSE'),
('A001-L01-L02','A001', 'L01-L02',2, 'Submitted', 'TRUE', 'Present', '2025-09-15 10:35', 'https://submit.bcit.ca/comp2714/inlab/A001-L01-L02.pdf', '2025-09-17 11:35', 'https://submit.bcit.ca/comp2714/polished/A001-L01-L02.pdf', '7.0', '6.7', 'FALSE'),
('A002-L01-L01','A002', 'L01-L01',1, 'Submitted', 'TRUE', 'Present', '2025-09-08 10:45', 'https://submit.bcit.ca/comp2714/inlab/A002-L01-L01.pdf', '2025-09-09 12:45', 'https://submit.bcit.ca/comp2714/polished/A002-L01-L01.pdf', '8.5', '8.2', 'FALSE'),
('A002-L01-L02','A002', 'L01-L02',2, 'In Progress', 'TRUE', 'Present', '2025-09-15 10:45', 'https://submit.bcit.ca/comp2714/inlab/A002-L01-L02.pdf', NULL, NULL, NULL, NULL, 'FALSE'),
('A003-L01-L01','A003', 'L01-L01',1, 'Submitted', 'TRUE', 'Present', '2025-09-08 10:45', 'https://submit.bcit.ca/comp2714/inlab/A003-L01-L01.pdf', '2025-09-09 12:45', 'https://submit.bcit.ca/comp2714/polished/A003-L01-L01.pdf', '8.5', '8.2', 'FALSE'),
('A003-L01-L02','A003', 'L01-L02',2, 'Submitted', 'FALSE', 'Present', '2025-09-15 10:35', 'https://submit.bcit.ca/comp2714/inlab/A003-L01-L02.pdf', '2025-09-17 11:35', 'https://submit.bcit.ca/comp2714/polished/A003-L01-L02.pdf', '7.0', '6.7', 'FALSE'),
('B001-L02-L01','B001', 'L02-L01',1, 'Submitted', 'TRUE', 'Present', '2025-09-08 14:45', 'https://submit.bcit.ca/comp2714/inlab/B001-L02-L01.pdf', '2025-09-09 16:45', 'https://submit.bcit.ca/comp2714/polished/B001-L02-L01.pdf', '8.5', '8.2', 'FALSE'),
('B001-L02-L02','B001', 'L02-L02',2, 'Submitted', 'TRUE', 'Present', '2025-09-15 14:35', 'https://submit.bcit.ca/comp2714/inlab/B001-L02-L02.pdf', '2025-09-17 15:35', 'https://submit.bcit.ca/comp2714/polished/B001-L02-L02.pdf', '7.0', '6.7', 'FALSE'),
('B002-L02-L01','A002', 'L02-L01',1, 'Submitted', 'TRUE', 'Present', '2025-09-08 14:45', 'https://submit.bcit.ca/comp2714/inlab/B002-L02-L01.pdf', '2025-09-09 16:45', 'https://submit.bcit.ca/comp2714/polished/B002-L02-L01.pdf', '8.5', '8.2', 'FALSE'),
('B002-L02-L02','A002', 'L02-L02',2, 'In Progress', 'TRUE', 'Present', '2025-09-15 14:40', 'https://submit.bcit.ca/comp2714/inlab/B002-L02-L02.pdf', NULL, NULL, NULL, NULL, 'FALSE'),
('B003-L02-L01','B003', 'L02-L01',1, 'Submitted', 'TRUE', 'Present', '2025-09-08 14:45', 'https://submit.bcit.ca/comp2714/inlab/B003-L02-L01.pdf', '2025-09-09 16:45', 'https://submit.bcit.ca/comp2714/polished/B003-L02-L01.pdf', '8.5', '8.2', 'FALSE'),
('B003-L02-L02','B003', 'L02-L02',2, 'Submitted', 'TRUE', 'Present', '2025-09-15 14:35', 'https://submit.bcit.ca/comp2714/inlab/B003-L02-L02.pdf', '2025-09-17 15:35', 'https://submit.bcit.ca/comp2714/polished/B003-L02-L02.pdf', '7.0', '6.7', 'FALSE'),
('C001-L01-L01','C001', 'L03-L01',1, 'Submitted', 'TRUE', 'Present', '2025-09-09 19:45', 'https://submit.bcit.ca/comp2714/inlab/C001-L03-L01.pdf', '2025-09-10 21:45', 'https://submit.bcit.ca/comp2714/polished/C001-L03-L01.pdf', '8.5', '8.2', 'FALSE'),
('C001-L01-L02','C001', 'L03-L02',2, 'Submitted', 'TRUE', 'Present', '2025-09-16 19:35', 'https://submit.bcit.ca/comp2714/inlab/C001-L03-L02.pdf', '2025-09-18 20:35', 'https://submit.bcit.ca/comp2714/polished/C001-L03-L02.pdf', '7.0', '6.7', 'FALSE'),
('C002-L03-L01','C002', 'L03-L01',1, 'Submitted', 'TRUE', 'Present', '2025-09-09 19:45', 'https://submit.bcit.ca/comp2714/inlab/C002-L03-L01.pdf', '2025-09-10 21:45', 'https://submit.bcit.ca/comp2714/polished/C002-L03-L01.pdf', '8.5', '8.2', 'FALSE'),
('C002-L03-L02','C002', 'L03-L02',2, 'In Progress', 'TRUE', 'Present', '2025-09-16 19:40', 'https://submit.bcit.ca/comp2714/inlab/C002-L03-L02.pdf', NULL, NULL, NULL, NULL, 'FALSE'),
('C003-L03-L01','C003', 'L03-L01',1, 'Submitted', 'TRUE', 'Present', '2025-09-09 19:45', 'https://submit.bcit.ca/comp2714/inlab/C003-L03-L01.pdf', '2025-09-10 21:45', 'https://submit.bcit.ca/comp2714/polished/C003-L02-L01.pdf', '8.5', '8.2', 'FALSE'),
('C003-L03-L02','C003', 'L03-L02',2, 'Submitted', 'FALSE', 'Present', '2025-09-16 19:35', 'https://submit.bcit.ca/comp2714/inlab/C003-L03-L02.pdf', '2025-09-18 20:35', 'https://submit.bcit.ca/comp2714/polished/C003-L02-L02.pdf', '7.0', '6.7', 'FALSE'),
('D001-L04-L01','D001', 'L04-L01',1, 'Submitted', 'TRUE', 'Present', '2025-09-10 10:45', 'https://submit.bcit.ca/comp2714/inlab/D001-L04-L01.pdf', '2025-09-11 12:45', 'https://submit.bcit.ca/comp2714/polished/D001-L04-L01.pdf', '8.5', '8.2', 'FALSE'),
('D001-L04-L02','D001', 'L04-L02',2, 'Submitted', 'TRUE', 'Present', '2025-09-17 10:35', 'https://submit.bcit.ca/comp2714/inlab/D001-L04-L02.pdf', '2025-09-19 11:35', 'https://submit.bcit.ca/comp2714/polished/D001-L04-L02.pdf', '7.0', '6.7', 'FALSE'),
('D002-L04-L01','D002', 'L04-L01',1, 'Submitted', 'TRUE', 'Present', '2025-09-10 10:45', 'https://submit.bcit.ca/comp2714/inlab/D002-L04-L01.pdf', '2025-09-11 12:45', 'https://submit.bcit.ca/comp2714/polished/D002-L04-L01.pdf', '8.5', '8.2', 'FALSE'),
('D002-L04-L02','D002', 'L04-L02',2, 'In Progress', 'TRUE', 'Present', '2025-09-17 10:40', 'https://submit.bcit.ca/comp2714/inlab/D002-L04-L02.pdf', NULL, NULL, NULL, NULL, 'FALSE'),
('D003-L04-L01','D003', 'L04-L01',1, 'Submitted', 'TRUE', 'Present', '2025-09-10 10:45', 'https://submit.bcit.ca/comp2714/inlab/D003-L04-L01.pdf', '2025-09-11 12:45', 'https://submit.bcit.ca/comp2714/polished/D003-L04-L01.pdf', '8.5', '8.2', 'FALSE'),
('D003-L04-L02','D003', 'L04-L02',2, 'Submitted', 'FALSE', 'Present', '2025-09-17 10:35', 'https://submit.bcit.ca/comp2714/inlab/D003-L04-L02.pdf', '2025-09-19 11:35', 'https://submit.bcit.ca/comp2714/polished/D003-L04-L02.pdf', '7.0', '6.7', 'FALSE'),
('E001-L05-L01','E001', 'L05-L01',1, 'Submitted', 'TRUE', 'Present', '2025-09-10 14:45', 'https://submit.bcit.ca/comp2714/inlab/E001-L05-L01.pdf', '2025-09-11 16:45', 'https://submit.bcit.ca/comp2714/polished/E001-L05-L01.pdf', '8.5', '8.2', 'FALSE'),
('E001-L05-L02','E001', 'L05-L02',2, 'Submitted', 'TRUE', 'Present', '2025-09-17 14:35', 'https://submit.bcit.ca/comp2714/inlab/E001-L05-L02.pdf', '2025-09-19 15:35', 'https://submit.bcit.ca/comp2714/polished/E001-L05-L02.pdf', '7.0', '6.7', 'FALSE'),
('E002-L05-L01','E002', 'L05-L01',1, 'Submitted', 'TRUE', 'Present', '2025-09-10 14:45', 'https://submit.bcit.ca/comp2714/inlab/E002-L05-L01.pdf', '2025-09-11 16:45', 'https://submit.bcit.ca/comp2714/polished/E002-L05-L01.pdf', '8.5', '8.2', 'FALSE'),
('E002-L05-L02','E002', 'L05-L02',2, 'In Progress', 'TRUE', 'Present', '2025-09-17 14:40', 'https://submit.bcit.ca/comp2714/inlab/E002-L05-L02.pdf', NULL, NULL, NULL, NULL, 'FALSE'),
('E003-L05-L01','E003', 'L05-L01',1, 'Submitted', 'TRUE', 'Present', '2025-09-10 14:45', 'https://submit.bcit.ca/comp2714/inlab/E003-L05-L01.pdf', '2025-09-11 16:45', 'https://submit.bcit.ca/comp2714/polished/E003-L05-L01.pdf', '8.5', '8.2', 'FALSE'),
('E003-L05-L02','E003', 'L05-L02',2, 'Submitted', 'FALSE', 'Present', '2025-09-17 14:35', 'https://submit.bcit.ca/comp2714/inlab/E003-L05-L02.pdf', '2025-09-19 15:35', 'https://submit.bcit.ca/comp2714/polished/E003-L05-L02.pdf', '7.0', '6.7', 'FALSE'),
('F001-L06-L01','F001', 'L06-L01',2, 'Submitted', 'TRUE', 'Present', '2025-09-11 19:45', 'https://submit.bcit.ca/comp2714/inlab/F001-L06-L02.pdf', '2025-09-12 21:45', 'https://submit.bcit.ca/comp2714/polished/F001-L06-L02.pdf', '7.0', '6.7', 'FALSE'),
('F001-L06-L02','F001', 'L06-L02',2, 'Submitted', 'TRUE', 'Present', '2025-09-18 19:35', 'https://submit.bcit.ca/comp2714/inlab/F001-L06-L02.pdf', '2025-09-20 20:35', 'https://submit.bcit.ca/comp2714/polished/F001-L06-L02.pdf', '7.0', '6.7', 'FALSE'),
('F002-L06-L01','F002', 'L06-L01',1, 'Submitted', 'TRUE', 'Present', '2025-09-11 19:45', 'https://submit.bcit.ca/comp2714/inlab/F002-L06-L01.pdf', '2025-09-12 21:45', 'https://submit.bcit.ca/comp2714/polished/F002-L06-L01.pdf', '8.5', '8.2', 'FALSE'),
('F002-L06-L02','F002', 'L06-L02',2, 'In Progress', 'TRUE', 'Present', '2025-09-18 19:40', 'https://submit.bcit.ca/comp2714/inlab/F002-L06-L02.pdf', NULL, NULL, NULL, NULL, 'FALSE'),
('F003-L06-L01','F003', 'L06-L01',1, 'Submitted', 'TRUE', 'Present', '2025-09-11 19:45', 'https://submit.bcit.ca/comp2714/inlab/F003-L06-L01.pdf', '2025-09-12 21:45', 'https://submit.bcit.ca/comp2714/polished/F003-L06-L01.pdf', '8.5', '8.2', 'FALSE'),
('F003-L06-L02','F003', 'L06-L02',2, 'Submitted', 'FALSE', 'Present', '2025-09-18 19:35', 'https://submit.bcit.ca/comp2714/inlab/F003-L06-L02.pdf', '2025-09-20 20:35', 'https://submit.bcit.ca/comp2714/polished/F003-L06-L02.pdf', '7.0', '6.7', 'FALSE');
-- Insert progress change logs
INSERT INTO progress_change_log
(chl_change_id, chl_progress_id, chl_changed_by, chl_changed_at, chl_field, chl_old_value, chl_new_value, chl_reason)
VALUES
('chg1', 'A001-L01-L01', 'u_instructor', '2025-09-09 12:10', 'instructor_assessment', '8.0', '8.5', 'Regraded after resubmission'),
('chg2', 'A003-L01-L02', 'u_ta1', '2025-09-16 20:45', 'status', 'In Progress', 'Submitted', 'Student submitted during lab; TA marked as submitted'),
('chg3', 'B003-L02-L01', 'u_system', '2025-09-23 23:59', 'late', 'False', 'True', 'Auto-flagged after set-specific due time');
+42
View File
@@ -0,0 +1,42 @@
-- Show all students with their section info Should work
SELECT s.student_first_name, s.student_last_name, ls.lab_course_code, c.course_title, t.term_name
FROM student s
JOIN student_section ss ON s.student_id = ss.ss_student_id
JOIN lab_section ls ON ss.ss_section_id = ls.lab_section_id
JOIN course c ON ls.lab_course_code = c.course_code
JOIN term t ON ls.lab_term_code = t.term_code;
-- Count students per lab section Should work
SELECT ls.lab_course_code, COUNT(ss.ss_student_id) AS total_students
FROM lab_section ls
LEFT JOIN student_section ss ON ls.lab_section_id = ss.ss_section_id
GROUP BY ls.lab_course_code;
-- View audit log Should work as intended
SELECT pcl.chl_change_id, ua.user_full_name AS actor, pcl.chl_reason, pcl.chl_changed_at
FROM progress_change_log pcl
JOIN user_account ua ON pcl.chl_changed_by = ua.user_id;
-- returns students names and sets
SELECT student_first_name, student_last_name, student_set_code
FROM student ORDER BY student_set_code ASC;
-- This should fail and not work
INSERT INTO course (course_code, course_title, credits)
VALUES ('COMP9999', 'Invalid Credits', 0);
-- Delete a lab section -> should also delete lab_event
-- and progress automatically cause of cascade
DELETE FROM lab_section WHERE lab_section_id = 'L01';
-- Check remaining events and progress
-- all should be empty due to cascade
SELECT * FROM lab_event WHERE lab_event.le_section_id = 'L01';
SELECT * FROM progress JOIN lab_event ON progress.pgr_event_id = lab_event.le_id
WHERE lab_event.le_section_id = 'L01';
SELECT * FROM progress_change_log JOIN progress ON progress_change_log.chl_progress_id = progress.pgr_id
JOIN lab_event ON progress.pgr_event_id = lab_event.le_id
WHERE lab_event.le_section_id = 'L01';