Database schema:

CREATE TABLE "current-terms" (
	address TEXT -- example: ['713 HART SENATE OFFICE BUILDING WASHINGTON DC 2051', '713 Hart Senate Office Building Washington DC 2051'],
	bioguide TEXT -- example: ['A000055', 'A000360'],
	caucus TEXT -- example: ['Democrat'],
	chamber TEXT -- example: ['senate', 'house'],
	class REAL -- example: ['1.0', '2.0'],
	contact_form TEXT -- example: ['http://www.brown.senate.gov/contact', 'http://www.brown.senate.gov/contact/'],
	district REAL -- example: ['1.0', '13.0'],
	"end" TEXT -- example: ['2001-01-03', '1999-01-03'],
	fax TEXT -- example: ['202-228-6321', '202-228-0514'],
	last TEXT -- example: ['Menendez'],
	name TEXT -- example: ['Morris K. Udall', 'Stewart Lee Udall'],
	office TEXT -- example: ['713 Hart Senate Office Building', '311 Hart Senate Office Building'],
	party TEXT -- example: ['Republican', 'Democrat'],
	party_affiliations TEXT -- example: ["{'start': '2009-01-06', 'end': '2009-02-23', 'part", "{'start': '1993-01-05', 'end': '1994-11-09', 'part"],
	phone TEXT -- example: ['202-224-2315', '202-224-3441'],
	relation TEXT -- example: ['son', 'nephew'],
	rss_url TEXT -- example: ['http://www.brown.senate.gov/rss/feeds/?type=all&am', 'http://www.cantwell.senate.gov/public/index.cfm/rs'],
	start TEXT -- example: ['1993-01-05', '1995-01-04'],
	state TEXT -- example: ['WA', 'OH'],
	state_rank TEXT -- example: ['senior', 'junior'],
	title TEXT -- example: ['Minority Whip', 'Majority Whip'],
	type TEXT -- example: ['rep', 'sen'],
	url TEXT -- example: ['http://brown.senate.gov/', 'http://www.house.gov/sherrodbrown'],
	PRIMARY KEY (bioguide, "end"), 
	CONSTRAINT fk_current-terms_current FOREIGN KEY(bioguide) REFERENCES current (bioguide_id)
)


CREATE TABLE "historical-terms" (
	address TEXT -- example: ['248 RUSSELL SENATE OFFICE BUILDING WASHINGTON DC 2', '359 DIRKSEN SENATE OFFICE BUILDING WASHINGTON DC 2'],
	bioguide TEXT -- example: ['A000001', 'A000002'],
	chamber TEXT -- example: ['senate', 'house'],
	class REAL -- example: ['1.0', '2.0'],
	contact_form TEXT -- example: ['http://www.webb.senate.gov/contact.cfm', 'http://www.scottbrown.senate.gov/public/index.cfm/'],
	district REAL -- example: ['9.0', '2.0'],
	"end" TEXT -- example: ['1791-03-03', '1793-03-03'],
	fax TEXT -- example: ['202-228-6363', '202-226-6299'],
	last TEXT -- example: ['Levy', 'Lambert'],
	middle TEXT, 
	name TEXT, 
	office TEXT -- example: ['248 Russell Senate Office Building', '359 Dirksen Senate Office Building'],
	party TEXT -- example: ['Pro-Administration', 'Anti-Administration'],
	party_affiliations TEXT -- example: ["{'start': '2009-01-06', 'end': '2009-12-22', 'part", "{'start': '2003-01-07', 'end': '2004-08-09', 'part"],
	phone TEXT -- example: ['202-224-4024', '202-224-4543'],
	relation TEXT, 
	rss_url TEXT -- example: ['http://www.begich.senate.gov/public/?a=rss.feed', 'http://radel.house.gov/news/rss.aspx'],
	start TEXT -- example: ['1790-01-01', '1789-03-04'],
	state TEXT -- example: ['VA', 'DE'],
	state_rank TEXT -- example: ['junior', 'senior'],
	title TEXT -- example: ['Majority Leader', 'Speaker'],
	type TEXT -- example: ['rep', 'sen'],
	url TEXT -- example: ['http://edwards.senate.gov/', 'http://fitzgerald.senate.gov/'],
	PRIMARY KEY (bioguide), 
	CONSTRAINT fk_historical-terms_historical FOREIGN KEY(bioguide) REFERENCES historical (bioguide_id)
)


CREATE TABLE "social-media" (
	bioguide TEXT -- example: ['A000055', 'A000360'],
	facebook TEXT -- example: ['congresswomanaumuaamata', 'RepToddYoung'],
	facebook_id REAL -- example: ['186203844738421.0', '1537155909907320.0'],
	govtrack REAL -- example: ['412428.0', '412664.0'],
	instagram TEXT -- example: ['senatorwarner', 'senjoniernst'],
	instagram_id REAL -- example: ['515327940.0', '1582702853.0'],
	thomas INTEGER -- example: ['2222', '2019'],
	twitter TEXT -- example: ['RepToddYoung', 'RepAmata'],
	twitter_id REAL -- example: ['3026622545.0', '234128524.0'],
	youtube TEXT -- example: ['RepToddYoung', 'RepYoder'],
	youtube_id TEXT -- example: ['UCGdrLQbt1PYDTPsampx4t1A', 'UCuknj4PGn91gHDNAfboZEgQ'],
	PRIMARY KEY (bioguide), 
	CONSTRAINT fk_social-media_current FOREIGN KEY(bioguide) REFERENCES current (bioguide_id)
)


CREATE TABLE current (
	ballotpedia_id TEXT -- example: ['Maria Cantwell', 'Sherrod Brown'],
	bioguide_id TEXT -- example: ['A000055', 'A000360'],
	birthday_bio DATE -- example: ['1958-10-13', '1952-11-09'],
	cspan_id REAL -- example: ['5.0', '45516.0'],
	fec_id TEXT -- example: ["['S8WA00194', 'H2WA01054']", "['H2OH13033', 'S6OH00163']"],
	first_name TEXT -- example: ['Maria', 'Sherrod'],
	gender_bio TEXT -- example: ['M', 'F'],
	google_entity_id_id TEXT -- example: ['kg:/m/034s80', 'kg:/m/01x68t'],
	govtrack_id INTEGER -- example: ['300018', '400050'],
	house_history_id REAL -- example: ['10608.0', '9996.0'],
	icpsr_id REAL -- example: ['29389.0', '39310.0'],
	last_name TEXT -- example: ['Cantwell', 'Brown'],
	lis_id TEXT -- example: ['S275', 'S307'],
	maplight_id REAL -- example: ['168.0', '544.0'],
	middle_name TEXT -- example: ['Richard', 'L.'],
	nickname_name TEXT -- example: ['Bernie', 'Bob'],
	official_full_name TEXT -- example: ['Maria Cantwell', 'Sherrod Brown'],
	opensecrets_id TEXT -- example: ['N00007836', 'N00003535'],
	religion_bio TEXT -- example: ['Roman Catholic', 'Lutheran'],
	suffix_name TEXT -- example: ['Jr.', 'III'],
	thomas_id INTEGER -- example: ['172', '136'],
	votesmart_id REAL -- example: ['27122.0', '27018.0'],
	wikidata_id TEXT -- example: ['Q381880', 'Q22250'],
	wikipedia_id TEXT -- example: ['Maria Cantwell', 'Sherrod Brown'],
	PRIMARY KEY (bioguide_id, cspan_id)
)


CREATE TABLE historical (
	ballotpedia_id TEXT -- example: ['Jo Bonner', 'Mo Cowan'],
	bioguide_id TEXT -- example: ['A000001', 'A000002'],
	bioguide_previous_id TEXT -- example: ["['F000246']", "['L000266']"],
	birthday_bio TEXT -- example: ['1742-03-21', '1745-04-02'],
	cspan_id TEXT -- example: ['12590.0', '4479.0'],
	fec_id TEXT -- example: ["['S2MN00126']", "['S6CO00168']"],
	first_name TEXT -- example: ['Richard', 'Theodorick'],
	gender_bio TEXT -- example: ['M', 'F'],
	google_entity_id_id TEXT -- example: ['kg:/m/02pz46', 'kg:/m/033mf4'],
	govtrack_id INTEGER -- example: ['401222', '401521'],
	house_history_alternate_id TEXT, 
	house_history_id REAL -- example: ['9479.0', '10177.0'],
	icpsr_id REAL -- example: ['507.0', '786.0'],
	last_name TEXT -- example: ['Bland', 'Bassett'],
	lis_id TEXT -- example: ['S134', 'S135'],
	maplight_id TEXT -- example: ['581.0', '232.0'],
	middle_name TEXT -- example: ['Samuel', 'Henry'],
	nickname_name TEXT -- example: ['of Colchester', 'of Carrollton'],
	official_full_name TEXT -- example: ['Enid Greene Waldholtz', 'Jesse L. Jackson Jr.'],
	opensecrets_id TEXT -- example: ['N00008333', 'N00006953'],
	religion_bio TEXT -- example: ['Roman Catholic', 'Baptist'],
	suffix_name TEXT -- example: ['Sr.', 'Jr.'],
	thomas_id TEXT -- example: ['01308', '01270'],
	votesmart_id TEXT -- example: ['128775.0', '52156.0'],
	wikidata_id TEXT -- example: ['Q1749152', 'Q518823'],
	wikipedia_id TEXT -- example: ['Richard Bassett (politician)', 'Theodorick Bland (congressman)'],
	PRIMARY KEY (bioguide_id)
)

Question: Among all the female current legislators, how many of them have served for more than 4 terms?
Evidence: female refers to gender_bio = 'F'; served for more than 4 terms refers to COUNT(bioguide > 4)

SQL:
SELECT COUNT(CID) FROM ( SELECT T1.bioguide_id AS CID FROM current AS T1 INNER JOIN `current-terms` AS T2 ON T1.bioguide_id = T2.bioguide WHERE T1.gender_bio = 'F' GROUP BY T2.bioguide HAVING COUNT(T2.bioguide) > 4 )