Search Mailing List Archives
[protege-discussion] DataMaster - mapping columns to class members
Paul Smith
paulsmith7777777 at yahoo.com
Fri Mar 28 11:33:55 PDT 2008
Csongor Nyulas <csongor.nyulas <at> stanford.edu> writes:
>
>
> Dear Paul,
> First of all sorry that I could not answer earlier.
> My solution b) should work fine if you exactly follow the steps I gave.
> I just tested it and I had no problem importing instances from a
> database to a compatible, previously existent ontology.
> See my detailed answer below.
> Paul Smith wrote:
>
> Csongor Nyulas <csongor.nyulas <at> stanford.edu> writes:
>
>
>
> Dear Paul,
>
>
> If you are importing data in an OWL ontology you can't avoid generating
> the prefix with DataMaster and I think this is logically correct so. By
> using the prefix/namespace mechanism each database will get a unique
> identifier, a namespace, and this will help to keep your imported
> concepts clean. How would you deal otherwise with a situation where you
> would have to import in your ontology db structure or data from two
> databases both having a table named Person, or in one databases the
> SALARY column would have type float and in the other long.
> The trick is in preparing your preexisting ontology to match the
> structure DataMaster would create and the step-by-step instructions I
> gave at my solution b) should do the trick. Important is (even if I put
> it in parenthesis before) that you define in your ontology using the
OntologyMetadataTab
> a prefix ("db" or another arbitrary prefix) for the namespace that
> DataMaster would generate for your database connection. You can find
> out this namespace from the temporary ontology I recommended you to
> create in the first step. This namespace would look something
like:http://biostorm.stanford.edu/db_table_classes?
DSN=jdbc:mysql://host:3306/database#
> After you created this prefix/namespace pair in your ontology you can
> rename your classes and properties using that prefix to exactly match
> the names DataMaster would generate for your tables and columns. For
> example if you have the following class in your ontology: Person
(name, age, race)
> and the following table in your DB: IDIVIDUAL(FULL_NAME, SEX, AGE,
PLACE_OF_BIRTH)
> You should create a prefix (let's say "db") as described above, and
> rename your classes and properties according to the names DataMaster
> would generate during the import (you can learn about those names too
> from your temporary ontology). After the renaming, your previous class
> would look like: db:INDIVIDUAL(db:FULL_NAME, db:AGE, race)
> Now you are ready to import instances from your DB. After the import
> your class will look like db:INDIVIDUAL(db:FULL_NAME, db:AGE, race,
db:SEX,
> db:PLACE_OF_BIRTH)
> Now you can rename your classes and properties to their original
names: Person(name, age, race, db:SEX, db:PLACE_OF_BIRTH)
> If you wish, you can even delete the additional imported properties
> that you don't need, and you are back at your original ontology
> structure, with the difference that now you have instances for your
> classes. Person(name, age, race)
> Please pay attention also to the data types of your properties. They
> too have to match the types generate by DataMaster!
> Let me know if you have succeeded with your import.
> Csongor
>
Hello Csongor
Ok, your method (b) works, I have put in practice. Thanks you very much. Now I
get the instances imported in the right place and with some little editing
work I can bring back the classes of my ontology to their original namespace.
The method applies also to the property of classes, with some extra
complication however: In fact a direct object properties is correctly imported
in the ontology, but there is no way to obtain its inverse property. Yes, I
could create the inverse property later, but then I had to fill the slots
manually.
One additional desired feature of your method would be to assign to the
imported instances a name extracted from a specific column of the database,
can you figure how to do that?
Thanks again
Paul
More information about the protege-discussion
mailing list