Look into creating a query language that deals with objects rather than SQL, to allow the creation of custom queries without writing SQL code.