More complicated relations in database