-- hrtime - transgender survey website
-- Copyright (C) 2025 Olive <hello@grasswren.net>
-- see LICENCE file for licensing information

CREATE TABLE IF NOT EXISTS entry (
	id INTEGER PRIMARY KEY,
	timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,

	birthdate DATETIME NOT NULL,
	country TEXT NOT NULL,

	medication TEXT NOT NULL,
	conditions TEXT NOT NULL,
	other TEXT NOT NULL,
	blood_test BOOLEAN NOT NULL,

	feedback TEXT NOT NULL,
	heard TEXT NOT NULL
);

CREATE TABLE IF NOT EXISTS gender (
	id INTEGER PRIMARY KEY,
	entry INTEGER NOT NULL,

	male BOOLEAN NOT NULL,
	female BOOLEAN NOT NULL,
	nonbinary BOOLEAN NOT NULL,
	agender BOOLEAN NOT NULL,
	genderfluid BOOLEAN NOT NULL,
	genderqueer BOOLEAN NOT NULL,
	demigender BOOLEAN NOT NULL,
	questioning BOOLEAN NOT NULL,
	other BOOLEAN NOT NULL,

	FOREIGN KEY(entry) REFERENCES entry(id)
);

CREATE TABLE IF NOT EXISTS ethnicity (
	id INTEGER PRIMARY KEY,
	entry INTEGER NOT NULL,

	african_american BOOLEAN NOT NULL,
	east_asian BOOLEAN NOT NULL,
	south_asian BOOLEAN NOT NULL,
	southeast_asian BOOLEAN NOT NULL,
	hispanic BOOLEAN NOT NULL,
	middle_eastern_north_african BOOLEAN NOT NULL,
	subsaharan_african BOOLEAN NOT NULL,
	white BOOLEAN NOT NULL,
	native_american BOOLEAN NOT NULL,
	pacific_islander BOOLEAN NOT NULL,
	other BOOLEAN NULL,

	FOREIGN KEY(entry) REFERENCES entry(id)
);

CREATE TABLE IF NOT EXISTS medication (
	id INTEGER PRIMARY KEY,
	entry INTEGER NOT NULL,

	med TEXT NOT NULL,
	method TEXT NOT NULL,
	amount TEXT NOT NULL,
	frequency TEXT NOT NULL,
	start DATETIME NOT NULL,
	end DATETIME NOT NULL,
	ongoing BOOLEAN NOT NULL,
	stop_reason TEXT NOT NULL,

	FOREIGN KEY(entry) REFERENCES entry(id)
);

CREATE TABLE IF NOT EXISTS masculine (
	id INTEGER PRIMARY KEY,
	entry INTEGER NOT NULL,

-- skin
	thicker_skin BOOLEAN NOT NULL,
	acne_oily_skin BOOLEAN NOT NULL,
	stronger_nails BOOLEAN NOT NULL,
	increased_perspiration BOOLEAN NOT NULL,
	decreased_perspiration BOOLEAN NOT NULL,
	body_odour BOOLEAN NOT NULL,

-- hair
	facial_body_hair_growth BOOLEAN NOT NULL,
	male_pattern_baldness BOOLEAN NOT NULL,

-- body shape
	weight_gain BOOLEAN NOT NULL,
	pelvic_bone_structure BOOLEAN NOT NULL,
	fat_redistribution BOOLEAN NOT NULL,
	increased_muscle_mass BOOLEAN NOT NULL,
	face BOOLEAN NOT NULL,

-- emotions
	increased_irritability BOOLEAN NOT NULL,
	sex_orientation BOOLEAN NOT NULL,

-- sensation
	improved_smell BOOLEAN NOT NULL,
	worsened_smell BOOLEAN NOT NULL,
	dulled_taste_smell BOOLEAN NOT NULL,

-- miscellaneous
	deeper_voice BOOLEAN NOT NULL,
	cessation_of_menstruation BOOLEAN NOT NULL,
	sleep_apnea BOOLEAN NOT NULL,
	rise_in_cholesterol BOOLEAN NOT NULL,
	high_blood_pressure BOOLEAN NOT NULL,
	polycythemia BOOLEAN NOT NULL,
	cramps BOOLEAN NOT NULL,

	increased_appetite BOOLEAN NOT NULL,
	decreased_appetite BOOLEAN NOT NULL,
	increased_drug_tolerance BOOLEAN NOT NULL,
	decreased_drug_tolerance BOOLEAN NOT NULL,
	improved_sleep BOOLEAN NOT NULL,
	worsened_sleep BOOLEAN NOT NULL,
	feeling_warmer BOOLEAN NOT NULL,
	feeling_colder BOOLEAN NOT NULL,
	other TEXT NOT NULL,

	FOREIGN KEY(entry) REFERENCES entry(id)
);

CREATE TABLE IF NOT EXISTS masculine_sex (
	id INTEGER PRIMARY KEY,
	entry INTEGER NOT NULL,

	genital_moisture_odour BOOLEAN NOT NULL,

	clitoral_growth BOOLEAN NOT NULL,
	vaginal_atrophy BOOLEAN NOT NULL,
	vaginal_dryness BOOLEAN NOT NULL,
	vaginal_discharge BOOLEAN NOT NULL,

	genital_sensitivity BOOLEAN NOT NULL,

	orgasm BOOLEAN NOT NULL,
	increased_libido BOOLEAN NOT NULL,
	decreased_libido BOOLEAN NOT NULL,

	other TEXT NOT NULL,

	FOREIGN KEY(entry) REFERENCES entry(id)
);

CREATE TABLE IF NOT EXISTS feminine (
	id INTEGER PRIMARY KEY,
	entry INTEGER NOT NULL,

-- skin
	softer_skin BOOLEAN NOT NULL,
	less_oily_skin BOOLEAN NOT NULL,
	thinner_softer_fingernails BOOLEAN NOT NULL,
	increased_perspiration BOOLEAN NOT NULL,
	decreased_perspiration BOOLEAN NOT NULL,
	body_odour BOOLEAN NOT NULL,

-- hair
	reduced_body_hair BOOLEAN NOT NULL,
	hairline BOOLEAN NOT NULL,

-- body shape
	slimmer_hands_wrists BOOLEAN NOT NULL,
	smaller_feet BOOLEAN NOT NULL,
	breast_growth BOOLEAN NOT NULL,
	fat_redistribution BOOLEAN NOT NULL,
	reduced_muscle_mass BOOLEAN NOT NULL,
	face BOOLEAN NOT NULL,

-- emotions
	increased_emotionality_sensitivity BOOLEAN NOT NULL,
	sex_orientation BOOLEAN NOT NULL,

-- sensation
	improved_smell BOOLEAN NOT NULL,
	worsened_smell BOOLEAN NOT NULL,
	taste BOOLEAN NOT NULL,

-- miscellaneous
	increased_flexibility BOOLEAN NOT NULL,

	increased_appetite BOOLEAN NOT NULL,
	decreased_appetite BOOLEAN NOT NULL,
	increased_drug_tolerance BOOLEAN NOT NULL,
	decreased_drug_tolerance BOOLEAN NOT NULL,
	feeling_warmer BOOLEAN NOT NULL,
	feeling_colder BOOLEAN NOT NULL,
	improved_sleep BOOLEAN NOT NULL,
	worsened_sleep BOOLEAN NOT NULL,

	other TEXT NOT NULL,

-- cyclical
	cramping BOOLEAN NOT NULL,
	bloating BOOLEAN NOT NULL,
	gas BOOLEAN NOT NULL,
	unstable_emotions BOOLEAN NOT NULL,
	pains BOOLEAN NOT NULL,
	breast_tenderness BOOLEAN NOT NULL,
	acne BOOLEAN NOT NULL,
	fatigue BOOLEAN NOT NULL,
	appetite_cravings BOOLEAN NOT NULL,
	migranes BOOLEAN NOT NULL,

	cycle TEXT NOT NULL,

	FOREIGN KEY(entry) REFERENCES entry(id)
);

CREATE TABLE IF NOT EXISTS feminine_sex (
	id INTEGER PRIMARY KEY,
	entry INTEGER NOT NULL,

	genital_moisture_odour BOOLEAN NOT NULL,
	genital_color_texture BOOLEAN NOT NULL,

	fewer_erections BOOLEAN NOT NULL,
	clear_ejaculate BOOLEAN NOT NULL,
	testicular_atrophy BOOLEAN NOT NULL,

	increased_genital_sensitivity BOOLEAN NOT NULL,
	genital_response BOOLEAN NOT NULL,

	orgasm BOOLEAN NOT NULL,
	increased_libido BOOLEAN NOT NULL,
	decreased_libido BOOLEAN NOT NULL,

	other TEXT NOT NULL,

	FOREIGN KEY(entry) REFERENCES entry(id)
);
