
CREATE TABLE item (
	i_id INTEGER NOT NULL, 
	title VARCHAR(20) DEFAULT NULL, 
	PRIMARY KEY (i_id)
)


CREATE TABLE review (
	a_id INTEGER NOT NULL, 
	u_id INTEGER NOT NULL, 
	i_id INTEGER NOT NULL, 
	rating INTEGER DEFAULT NULL, 
	rank INTEGER DEFAULT NULL, 
	PRIMARY KEY (a_id), 
	FOREIGN KEY(i_id) REFERENCES item (i_id), 
	FOREIGN KEY(u_id) REFERENCES useracct (u_id)
)


CREATE TABLE trust (
	source_u_id INTEGER NOT NULL, 
	target_u_id INTEGER NOT NULL, 
	trust INTEGER NOT NULL, 
	FOREIGN KEY(target_u_id) REFERENCES useracct (u_id), 
	FOREIGN KEY(source_u_id) REFERENCES useracct (u_id)
)


CREATE TABLE useracct (
	u_id INTEGER NOT NULL, 
	name VARCHAR(128) DEFAULT NULL, 
	PRIMARY KEY (u_id)
)

CREATE TABLE item (
	i_id INTEGER NOT NULL, 
	title VARCHAR(20) DEFAULT NULL, 
	PRIMARY KEY (i_id)
)

/*
2 rows from item table:
i_id	title
0	pear
1	orange
*/


CREATE TABLE review (
	a_id INTEGER NOT NULL, 
	u_id INTEGER NOT NULL, 
	i_id INTEGER NOT NULL, 
	rating INTEGER DEFAULT NULL, 
	rank INTEGER DEFAULT NULL, 
	PRIMARY KEY (a_id), 
	FOREIGN KEY(i_id) REFERENCES item (i_id), 
	FOREIGN KEY(u_id) REFERENCES useracct (u_id)
)

/*
2 rows from review table:
a_id	u_id	i_id	rating	rank
1	1	1	10	1
2	2	1	5	2
*/


CREATE TABLE trust (
	source_u_id INTEGER NOT NULL, 
	target_u_id INTEGER NOT NULL, 
	trust INTEGER NOT NULL, 
	FOREIGN KEY(target_u_id) REFERENCES useracct (u_id), 
	FOREIGN KEY(source_u_id) REFERENCES useracct (u_id)
)

/*
2 rows from trust table:
source_u_id	target_u_id	trust
1	2	10
1	3	6
*/


CREATE TABLE useracct (
	u_id INTEGER NOT NULL, 
	name VARCHAR(128) DEFAULT NULL, 
	PRIMARY KEY (u_id)
)

/*
2 rows from useracct table:
u_id	name
1	Helen
2	Mark
*/
How many different users wrote some reviews?
SELECT count(DISTINCT u_id) FROM review
[{'count(DISTINCT u_id)': 2}]