gist, but not working correctly

this almost works, but fails a foreign key restraint. at least this is a
database problem and not a web problem