The Semantic Web provides a common framework that allows data to be shared and reused across
applications, enterprises, and community boundaries. The existing web applications need to express
semantics that can be extracted from users' navigation and content, in order to fulfill users' needs. Elearning
has specific requirements that can be satisfied through the extraction of semantics from learning
management systems (LMS) that use relational databases (RDB) as backend. In this paper, we propose
transformation rules for building owl ontology from the RDB of the open source LMS Moodle. It allows
transforming all possible cases in RDBs into ontological constructs. The proposed rules are enriched by
analyzing stored data to detect disjointness and totalness constraints in hierarchies, and calculating the
participation level of tables in n-ary relations. In addition, our technique is generic; hence it can be applied
to any RDB.