How relationships affect a query result