An important policy debate, particularly in the digital economy, surrounds the role data plays in competition. However, attempts to provide a coherent economic analysis have been stymied by the fact that data has many forms and many different uses. We develop general conditions under which the accumulation of data by firms is pro- or anti-competitive, and use these conditions to examine the competitive effects of data in applications such as targeted advertising, product personalisation, algorithmic recommendations, and price discrimination. We also apply this framework to study policy issues such as the control of mergers where data changes hands, the design of privacy policy, and the implications of data for long-run market dynamics.