CREATE TABLE courses(
	crn TEXT NOT NULL PRIMARY KEY,
	term_code TEXT NOT NULL,
	subj_code TEXT NOT NULL,
	crse_numb TEXT NOT NULL,
	crse_title TEXT,
	crse_equiv TEXT,
	crse_text TEXT,
	note_row TEXT,
	ptrm_code TEXT,
	seq_numb TEXT,
	schd_code TEXT,
	schd_type TEXT,
	schd_sort INTEGER,
	link_conn TEXT,
	start_date TEXT,
	end_date TEXT,
	max_enrl INTEGER,
	enrl INTEGER,
	seats INTEGER,
	wlist INTEGER,
	xlist_max INTEGER,
	xlist_cur INTEGER,
	instructors TEXT,
	note_bottom TEXT
);

CREATE TABLE schedules (
	id INTEGER PRIMARY KEY AUTOINCREMENT,
	crn TEXT NOT NULL,
	location TEXT,
	start_time TEXT,
	end_time TEXT,
	start_date TEXT,
	end_date TEXT,
	monday BOOLEAN DEFAULT 0,
	tuesday BOOLEAN DEFAULT 0,
	wednesday BOOLEAN DEFAULT 0,
	thursday BOOLEAN DEFAULT 0,
	friday BOOLEAN DEFAULT 0,
	saturday BOOLEAN DEFAULT 0,
	sunday BOOLEAN DEFAULT 0,
	FOREIGN KEY (crn) REFERENCES courses(crn) ON DELETE CASCADE
);

CREATE INDEX courses_subjnumb_idx ON courses(subj_code, crse_numb);
