In order to create clusters based on foursquare categories, we first made a table in PostgreSQL called upperlevelcat and assigned a gid for each of the nine categories.
To link these categories to venues, we did a double join : fscategory table, fsvenue, and fsvenue_fscategory tables.
SQL statement for double join:
SELECT v.herenow, v.checkinct, v.userct, join1.upperlevelcat, join1.name as catname, v.name as venuename,v.lat,v.lon,v.geom
FROM (SELECT * from fsvenue_fscategory
LEFT JOIN fscategory as fsc ON fsc.fsid=fsvenue_fscategory.cid) AS join1
LEFT JOIN fsvenue as v ON v.fsid=join1.vid