Database schema:

CREATE TABLE atom (
	atom_id TEXT NOT NULL -- atom id, example: ['TR000_1', 'TR000_2'],
	molecule_id TEXT DEFAULT NULL -- molecule id, example: ['TR000', 'TR001'],
	element TEXT DEFAULT NULL -- example: ['c', 'cl'],
	PRIMARY KEY (atom_id), 
	CONSTRAINT fk_atom_molecule FOREIGN KEY(molecule_id) REFERENCES molecule (molecule_id)
)


CREATE TABLE bond (
	bond_id TEXT NOT NULL -- example: ['TR000_2_3', 'TR000_1_2'],
	molecule_id TEXT DEFAULT NULL -- example: ['TR000', 'TR001'],
	bond_type TEXT DEFAULT NULL -- example: ['=', '-'],
	PRIMARY KEY (bond_id), 
	CONSTRAINT fk_bond_molecule FOREIGN KEY(molecule_id) REFERENCES molecule (molecule_id)
)


CREATE TABLE connected (
	atom_id TEXT NOT NULL -- atom id, example: ['TR000_1', 'TR000_2'],
	atom_id2 TEXT NOT NULL -- atom id 2, example: ['TR000_1', 'TR000_2'],
	bond_id TEXT DEFAULT NULL -- bond id, example: ['TR000_2_3', 'TR000_1_2'],
	PRIMARY KEY (atom_id, atom_id2), 
	CONSTRAINT fk_connected_bond FOREIGN KEY(bond_id) REFERENCES bond (bond_id),
	CONSTRAINT fk_connected_atom FOREIGN KEY(atom_id2) REFERENCES atom (atom_id),
	CONSTRAINT fk_connected_atom FOREIGN KEY(atom_id) REFERENCES atom (atom_id)
)


CREATE TABLE molecule (
	molecule_id TEXT NOT NULL -- molecule id, example: ['TR000', 'TR001'],
	label TEXT DEFAULT NULL -- example: ['+', '-'],
	PRIMARY KEY (molecule_id)
)

Question: What is the ratio of Hydrogen elements in molecule ID TR006? List the ratio with its label.
Evidence: hydrogen refers to element = 'h'; ratio = DIVIDE(SUM(element = 'h'), count(element)) where molecule_id = 'TR006' ; label = '+' mean molecules are carcinogenic; label = '-' means molecules are non-carcinogenic

SQL:
WITH SubQuery AS (SELECT DISTINCT T1.atom_id, T1.element, T1.molecule_id, T2.label FROM atom AS T1 INNER JOIN molecule AS T2 ON T1.molecule_id = T2.molecule_id WHERE T2.molecule_id = 'TR006') SELECT CAST(COUNT(CASE WHEN element = 'h' THEN atom_id ELSE NULL END) AS REAL) / (CASE WHEN COUNT(atom_id) = 0 THEN NULL ELSE COUNT(atom_id) END) AS ratio, label FROM SubQuery GROUP BY label