Database schema:

CREATE TABLE "RA" (
	student_id INTEGER -- example: ['2', '5'],
	capability INTEGER -- example: ['2', '5'],
	prof_id INTEGER -- example: ['7', '10'],
	salary TEXT -- example: ['med', 'high'],
	PRIMARY KEY (student_id, prof_id), 
	CONSTRAINT fk_ra_prof FOREIGN KEY(prof_id) REFERENCES prof (prof_id),
	CONSTRAINT fk_ra_student FOREIGN KEY(student_id) REFERENCES student (student_id)
)


CREATE TABLE course (
	course_id INTEGER -- example: ['2', '1'],
	name TEXT -- example: ['Machine Learning Theory', 'Intro to Database 1'],
	credit INTEGER -- example: ['2', '3'],
	diff INTEGER -- example: ['4', '3'],
	PRIMARY KEY (course_id)
)


CREATE TABLE prof (
	prof_id INTEGER -- example: ['2', '1'],
	gender TEXT -- example: ['Male', 'Female'],
	first_name TEXT -- example: ['Nathaniel', 'Zhihua'],
	last_name TEXT -- example: ['Pigford', 'Zhou'],
	email TEXT -- example: ['zzhihua@hku.hk', 'npigford0@hku.hk'],
	popularity INTEGER -- example: ['2', '3'],
	teachingability INTEGER -- example: ['5', '1'],
	graduate_from TEXT -- example: ['University of Washington', 'Beijing Polytechnic University'],
	PRIMARY KEY (prof_id)
)


CREATE TABLE registration (
	course_id INTEGER -- example: ['2', '1'],
	student_id INTEGER -- example: ['2', '3'],
	grade TEXT -- example: ['A', 'B'],
	sat INTEGER -- example: ['5', '4'],
	PRIMARY KEY (course_id, student_id), 
	CONSTRAINT fk_registration_course FOREIGN KEY(course_id) REFERENCES course (course_id),
	CONSTRAINT fk_registration_student FOREIGN KEY(student_id) REFERENCES student (student_id)
)


CREATE TABLE student (
	student_id INTEGER -- example: ['2', '1'],
	f_name TEXT -- example: ['Kerry', 'Chrysa'],
	l_name TEXT -- example: ['Dine-Hart', 'Pryor'],
	phone_number TEXT -- example: ['(243) 6836472', '(672) 9245255'],
	email TEXT -- example: ['kpryor0@hku.hk', 'cdinehart1@hku.hk'],
	intelligence INTEGER -- example: ['5', '2'],
	gpa REAL -- example: ['2.7', '2.4'],
	type TEXT -- example: ['RPG', 'TPG'],
	PRIMARY KEY (student_id)
)

Question: What is the average number of students who registered for the courses with a difficulty of 4?
Evidence: diff refers to difficulty; DIVIDE(COUNT(student_id where diff = 4), COUNT(course_id where diff = 4));

SQL:
SELECT CAST(COUNT(T1.student_id) AS REAL) / COUNT(DISTINCT T2.course_id) FROM registration AS T1 INNER JOIN course AS T2 ON T1.course_id = T2.course_id WHERE T2.diff = 4