you can achieve this with Dynamic Query.
I don't much know about PostgreSql, but I know SQL Server, so I am giving a example to do same.
Here is SQLFiddel Demo
Create table Product(pid int,name varchar(10),color varchar(10),brand varchar(10),size varchar(10));
insert into product values(1,'ABC','red','X','small');
create table pfrelation(pid int,fid int,relation varchar(100));
insert into pfrelation values(1,10,'Color=''blue''');
insert into pfrelation values(1,11,'Color=''black''');
insert into pfrelation values(1,13,'Color=''red''');
insert into pfrelation values(1,18,'size=''small''');
insert into pfrelation values(1,20,'brand=''X''');
Declare @sql varchar(200)
select @sql = ((select 'pr.' + relation from pfrelation where fid = 18)
+ ' and (' +
(select 'pr.' + relation from pfrelation where fid = 11)
+ ' or ' +
(select 'pr.' + relation from pfrelation where fid = 13)
+ ') and pr.pid=pf.pid' )
select @sql
print('select * from Product pr,pfrelation pf where '+@sql)
exec('select * from Product pr,pfrelation pf where '+@sql)