Data integration is the main problem encountered by applications that need to query across multiple autonomous and heterogeneous data sources. This paper addresses this problem using logic-based approach. We present a semantic integration infrastructure for relational data. In this integration infrastructure, ontology is used as the mediated schema. The formal semantics of SPARQL is defined according to the W3C candidate recommendation and translation algorithm from SPARQL to datalog is provided. A query rewriting algorithm based on datalog is also provided for heterogeneous data integration.