1

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. :'(

MT0
  • 143,790
  • 11
  • 59
  • 117

1 Answers1

4

Simple Data Mapping

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:

Inheritance

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.

Association

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:comments 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)

Aggregation

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.

Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
  • I have already implemented [link]http://www.w3.org/TR/rdb-direct-mapping/ . But there is no reference for mapping RDB Relationships. Also it should be independent of the data, as this mapping should work on any SQL Schema. Is there any predicate in RDFS, which relates to association and aggregation relationships? – Siddharth Singh Jun 01 '13 at 06:32
  • @SiddharthSingh Ah, OK. At first I thought this was just a question about how to represent relational data in RDF, but you're actually asking how to record some of the higher level connections. I have updated with some discussion of inheritance, association, and aggregation. There's only so much that you can do in RDF(S) alone, but if you also have the option of using OWL, you can probably capture all the relationships that you are interested in. – Joshua Taylor Jun 03 '13 at 14:18
  • @JoshuaTaylor , isn't aggregation and association different in most usual pragmatics: if we want to, say, delete, something, which is agregated, we should delete also aggregated information, while simply associated information could stay (it is "stand-alone"). That is, if we delete university, the faculty which is part-of university should also be deleted, but not professors, which are associated. I think it is important enough for modelling, and there ways to model that correctly both in RDB and RDF. – Roman Susi May 16 '15 at 12:57
  • @RomanSusi I'm not quite what you're getting at in this case. In describing a University, you'd probably have `:uniX a :University ; :hasFacultyMember :profY, :profZ .` If you get rid of all the triples involving `:uniX` (which is typically the way to "delete" a thing in RDF), you'll still have `:profY a :Professor . :profZ a :Professor`. – Joshua Taylor May 16 '15 at 13:03
  • @JoshuaTaylor Sure, but if I want the system to figure out what to delete when asked to delete University, then it stops before deleting profs, but happily deletes faculties. This is the main practical difference between aggregation and association. I guess, some transitive property could be used to hold university parts together, and deleted together. That is also what SemWeb for working ontologist tells about in a passage on whether Mick Jagger’s thumb is partOf Rolling Stones or not. – Roman Susi May 16 '15 at 13:14
  • According to this: http://stackoverflow.com/questions/9640885/uml-aggregation-vs-association I've mistaken Aggregation for Composition. If so understood, my comment is void, and your answer on Aggregation is perfect. – Roman Susi May 16 '15 at 13:25
  • WIkipedia explains it ironically with the same example as I used above: https://en.wikipedia.org/wiki/Object_composition#Aggregation – Roman Susi May 16 '15 at 13:28
  • 1
    @RomanSusi For a good read about partOf relationships in ontology languages, have a look at the W3C Editor's Note, [*Simple part-whole relations in OWL Ontologies*](http://www.w3.org/2001/sw/BestPractices/OEP/SimplePartWhole/). – Joshua Taylor May 16 '15 at 13:30