We present a two-sorted algebra, called a Peirce algebra, of relations and sets interacting with each other. In a Peirce algebra, sets can combine with each other as in a Boolean algebra, relations can combine with each other as in a relation algebra, and in addition we have both a relationforming operator on sets (the Peirce product of Boolean modules) and a set-forming operator on relations (a cylindrification operation). Two applications of Peirce algebras are given. The first points out that Peirce algebras provide a natural algebraic framework for modelling certain programming constructs. The second shows that the so-called terminological logics arising in knowledge representation have evolved a semantics best described as a calculus of relations interacting with sets.