Added new sql with defined relations