
CREATE TABLE query_sections (
	id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
	display_id TINYINT NOT NULL UNIQUE,
	name VARCHAR(255) NOT NULL UNIQUE
);

INSERT INTO query_sections (id, display_id, name) VALUES
	(1, 1, 'Site Risk Assessment'),
	(2, 2, 'Safety'),
	(3, 3, 'Environment'),
	(4, 4, 'Documentation'),
	(5, 5, 'Public Impact'),
	(6, 6, 'Traffic Control'),
	(7, 7, 'Plant and Machinery');

ALTER TABLE queries ADD COLUMN query_section_id INT;

UPDATE queries q JOIN inspection_queries iq ON iq.query_id = q.id SET q.query_section_id = SUBSTR(iq.display_id, 1, 1);
