improved getRealmForDbid(dbid)