Ontologies play an important role in representing the semantics of data sources. Building an ontology as a representation of domain knowledge from available data sources is not a simple process, particularly when dealing with relational data, which remains prevalent in existing knowledge systems. In this study, we create an ontology from a relational database using object-relational mapping (ORM) metadata as additional rules for mapping. Our method comprises two main phases: ontology schema construction using ORM metadata and the generation of ontology instances from the relational database. During the initial phase, we analyzed the ORM metadata to map it to an resource description framework schema (RDF(S))-OWL representation of the ontology. In the subsequent phase, we applied mapping rules to convert the relational database (RDB) data into ontological instances, which are then represented as RDF triples. Using ORM metadata, we enhance the accuracy of the resulting ontology, particularly in terms of extracting concepts and hierarchical relationships. This study contributes to the field of ontology learning by showcasing a novel approach that leverages ORM metadata to create ontologies from relational databases.