Reputation: 15
Currently I am working on Transforming Relational Database to RDF model. In relational database, three kinds of relationships are there : 1) inheritance, 2) association, 3) aggregation.
For mapping Inheritance relationship, I added a RDF triple,
{ Child_Table <rdfs:subClassOf> Parent_Table }
Is this how it's written? I want to map association and aggregation relationships to RDF model. What Predicates(properties) should I use for mapping association and aggregation relationship between tables? Its the schema i want to map.
Lets say there is aggregation relationship between TableA and TableB, is there any way to represent this relation in RDF, sumthing like.
{ tableA <predicate> tableB}
Please enlighten this noobie. :'(
Upvotes: 1
Views: 730
Reputation: 85873
There are lots of different ways to represent the data in relational databases in RDF, and the best way very much depends on the particular data you have at hand. You mention that you have inheritance, association, and aggregation relationships, but without examples of your data, it's hard to know what the best approach would be. You might be interested in some of the resources out there, though, such as:
The relationships of inheritance, association, and aggregation are usually discussed within the context of classes, which may or may not make sense in the context of relational databases. Without knowing how your information is represented in the database, it is hard to say whether
ChildTable rdfs:subClassOf ParentTable
makes sense or not. It seems to me that if you had, for instance, an Animal table, each row of which represents an individual instance of an animal, and then also had a Mammal table, each row of which represents an individual instance of a mammal, that each mammal instance would also have a key to its corresponding animal row. For instance, you might have the following tables:
Animal
AnimalId, LatinName, CasualName, FavoriteFood
71, Heloderma suspectum, "Jim the Gila Monster", "Eggs"
72, Canis lupus familiaris, "Semour", "Pizza"
73, Canis lupus familiaris, "Spot", "Kibble"
74, Felis catus, "Fluffy", "Fish"
75, Homo sapiens, "Fry", "Bachelor Chow"
Mammal
AnimalId, isBipedal
72, false
73, false
74, false
75, false
To represent the inheritance between mammals and animals, you could say that
Mammal rdfs:subClassOf Animal
You would need to ensure, of course, that the Mammal
with AnimalId 72
is the same resource as the Animal
with AnimalId 72
, but if you have already implemented the direct mapping of the relational data, this should not be a problem.
In pure RDF(S), you cannot do much more than inheritance. You can declare the domain and range of properties, of course, and infer some type information, but you really cannot do much in the way of ensuring that, for instance, each Animal
has at least one favorite food. At the very least, you should annotate your properties and classes with rdfs:comment
s to indicate what the data ought to include. For instance:
Animal rdfs:comment "Each animal instance MUST have:
exactly one ID (hasID);
exactly one latin name (hasLatinName); and
exactly one favorite food (hasFavoriteFood).
Each animal instance MAY have:
up to one casual name (hasCasualName)." .
If you can use OWL, however, you can express these types of relationships using restriction classes and subclass axioms. For instance, the following OWL axioms represent the constraints expressed in the preceding comment:
Animal SubClassOf (hasId exactly 1 xsd:integer)
Animal SubClassOf (hasLatinName exactly 1 xsd:string)
Animal SubClassOf (hasFavoriteFood exactly 1 xsd:string)
Animal SubClassOf (hasCasualName max 1 xsd:string)
RDF (and OWL) are for declaratively representing information about individuals, and not necessary the objects of object oriented programming. Since there is no built in concept of object lifetime or ownership, the distinction between association and aggregation largely disappears. The type of axioms that you can express in OWL will serve just as well to describe how a property fits into an aggregation relationship as they do for association relationships.
One point to be aware of, though, is that RDF and OWL classes are more properly thought of as sets, not object oriented programming classes. One nice feature of this is that, unlike many popular programming languages, classes are not restricted to having a single parent class. This means that some cases in object oriented programming where aggregation is necessary, the RDF analog of multiple inheritance works just as well.
Upvotes: 4