1

I’m trying to map a relational database to an ontology.

I read many approaches like 1 2 and they all agreed to model bridge tables (join table between two tables connected with each other with many-to-many relationship) as follows:

  1. If the bridge table contains exactly two foreign keys without presence of independent attributes, it can be mapped into two object properties, the latter is an inverse of the former.
  2. If the bridge table contains exactly two foreign keys with presence of independent attributes, it should be mapped into separate OWL classes.

With that in mind, if we have two tables: students and courses and the join table contains only three columns:

id, student_id, course_id

we model the ontology with two classes: student and course, and two relationships "object properties" :

student ---study---> course

course ---studied_by---> student

but if the join table contains one independent attribute or more, let's say it contains:

id, student_id, course_id, grade

then a new class should be created in the ontology. we model the ontology with three classes: student, course, student_course and two object properties :

student ---student_has---> student_course

course ---course_has---> student_course

is this the best solution?

sary Jou
  • 21
  • 3
  • 1
    Why exactly do you think your semantic model is impractical? – Richard-Degenne Nov 22 '22 at 13:27
  • 1
    If you want to put your model to the test, my suggestion would be to simulate some data in your relational database, and imagine what this data would look like in a graph form. – Richard-Degenne Nov 22 '22 at 14:14
  • What is your 1 specific researched non-duplicate question re how/why you are 1st stuck/unsure on what step among which in what published presentation of what process? [research effort](https://meta.stackoverflow.com/q/261592/3404097) [“help me"](https://meta.stackoverflow.com/q/284236/3404097) – philipxy Nov 22 '22 at 19:23
  • You didn't act on my last comment. PS "best" doesn't mean anything in particular. PS [Strategy for “Which is better” questions](https://meta.stackexchange.com/q/204461) [Why is asking a question on "best practice" a bad thing?](https://meta.stackexchange.com/q/142353/266284) – philipxy Nov 26 '22 at 21:22

1 Answers1

1

This feels like the wrong way of going about knowledge graph creation. This approach constrains you to the schema you have in your DB. Rather than relying on the shared attributes you have in your relational tables, you could start with a blank slate and design the ontology to your downstream use-case.

This paper from Stanford provides 7 clear steps how to create an ontology.. There are also a huge number of ontologies you can adapt to your use-case.

In terms of mapping data into the ontology, you could consider using something like RML.

HES
  • 160
  • 7