This paper proposes a novel approach to automatic transformation of relational databases to ontologies, where the quality of transformation is also considered. A relational database is written in SQL, and an ontology is written in OWL. The proposed approach can be used for upgrading today’s Web to the Semantic Web. The high cost of manual building ontologies from scratch is one of the main obstacles for the development of the Semantic Web. On the other hand, the Semantic Web can benefit from reuse of the vast amount of relational database information available on the Web today.