We present a formal analysis of the following view-selection problem: Given a set of queries and a database, return definitions of views that, when materialized in the database, would reduce the evaluation costs of the queries. Optimizing the layout of stored data using view selection has a direct impact on the performance of the entire database system. At the same time, the optimization problem is intractable, even under natural restrictions on the types of queries of interest. In this paper we use an integer-programming model to obtain optimal solutions to the problem of view selection for aggregate queries on data warehouses. We also report the results of the post-optimality analysis that we performed to determine/observe the impact of changing certain input characteristics on the optimal solution.