Describing relational data sources (i.e. databases) by means of ontologies constitutes the foundation of most of the semantic based approaches to data access and integration. In spite of the importance of the task this is mostly carried out manually and, to the best of our knowledge, not much research has been devoted to its automatisation. In this paper we introduce an automatic procedure for building ontologies starting from the integrity constraints present in the relational sources. Our work builds upon the wide literature on database schema reverse engineering; however, we adapt these techniques to the specific purpose of reusing the extracted schemata (or ontologies) in the context of semantic data access. In particular, we ensure that the underlying data sources can be queried through the ontologies and the extracted ontologies can be used for semantic integration using recently developed techniques in this area. In order to represent the extracted ontology we adopt a variant o...