How many people are a friend of Alice?
select count(*) from personfriend where name = 'Alice'
How many people are not a friend of Alice?
select count(*) from person where name not in (select friend from personfriend where name = 'Alice')
Who among the friends of Alice is male?
select t2.friend from person as t1 join personfriend as t2 on t1.name = t2.friend where t2.name = 'Alice' and t1.gender = 'male'
Only show those who are also a doctor?
select t2.friend from person as t1 join personfriend as t2 on t1.name = t2.friend where t2.name = 'Alice' and t1.gender = 'male' and t1.job = 'doctor'