In this paper a formal model for class and object diagrams is presented. To make the model the author used Alloy, which is a three- in-one package: a modeling language that constructs software models, a formal method that guides the construction of software models and an analyzer that helps find inconsistencies in software models. In the proposed model the entities that form class and object diagrams, as well as the rules that govern how these elements can be connected, are specified.