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: For the professors who advise more than 2 students, which professor has a higher teaching ability? Give the full name.
Evidence: professor advising more than 2 students refers to COUNT(student_id) > 2; higher teachability refers to MAX(teachingability); full name refers to f_name and l_name;

SQL:
SELECT T.first_name, T.last_name FROM ( SELECT T2.first_name, T2.last_name, T2.teachingability FROM RA AS T1 INNER JOIN prof AS T2 ON T1.prof_id = T2.prof_id GROUP BY T1.prof_id HAVING COUNT(student_id) > 2 ) T ORDER BY T.teachingability DESC LIMIT 1