create table attribute_table ( blob_uni int, attribute text, value text ); create unique index a_t_uni on attribute_table ( blob_uni, attribute ); #### select * from blob_table where id IN ( select blob_id from attribute_table where attribute='color' and value='red );