Margins of discrete Bayesian networks