Moving most of the markov logic into the database