Updated queries to match views in relational db