Solving Bayesian Problems using SQL