  The interplay between local consistency and global consistency has been the
object of study in several different areas, including probability theory,
relational databases, and quantum information. For relational databases, Beeri,
Fagin, Maier, and Yannakakis showed that a database schema is acyclic if and
only if it has the local-to-global consistency property for relations, which
means that every collection of pairwise consistent relations over the schema is
globally consistent. More recently, the same result has been shown under bag
semantics. In this paper, we carry out a systematic study of local vs.\ global
consistency for relations over positive commutative monoids, which is a common
generalization of ordinary relations and bags. Let $\mathbb K$ be an arbitrary
positive commutative monoid. We begin by showing that acyclicity of the schema
is a necessary condition for the local-to-global consistency property for
$\mathbb K$-relations to hold. Unlike the case of ordinary relations and bags,
however, we show that acyclicity is not always sufficient. After this, we
characterize the positive commutative monoids for which acyclicity is both
necessary and sufficient for the local-to-global consistency property to hold;
this characterization involves a combinatorial property of monoids, which we
call the \emph{transportation property}. We then identify several different
classes of monoids that possess the transportation property. As our final
contribution, we introduce a modified notion of local consistency of
$\mathbb{K}$-relations, which we call \emph{pairwise consistency up to the free
cover}. We prove that, for all positive commutative monoids $\mathbb{K}$, even
those without the transportation property, acyclicity is both necessary and
sufficient for every family of $\mathbb{K}$-relations that is pairwise
consistent up to the free cover to be globally consistent.
