Primary and Foreign Key Info in Ontology?

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Primary and Foreign Key Info in Ontology?

Tabbasum
Hi,

I am developing an ontology from a database.
Database tables are represented as classes in ontology. Tables fields are represented as properties in ontology.
I also want to store some information about primary and foreign keys from database.
Can anybody guide me how can I store primary key and foreign key information in an ontology?

Regards
Tabbasum


_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Primary and Foreign Key Info in Ontology?

Martin O'Connor
Have you looked at DataMaster:

http://protegewiki.stanford.edu/wiki/DataMaster

Martin

Tabbasum Naz wrote:

> Hi,
>
> I am developing an ontology from a database.
> Database tables are represented as classes in ontology. Tables fields
> are represented as properties in ontology.
> I also want to store some information about primary and foreign keys
> from database.
> Can anybody guide me how can I store primary key and foreign key
> information in an ontology?
>
> Regards
> Tabbasum
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> protege-owl mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-owl
>
> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
>  

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Primary and Foreign Key Info in Ontology?

Thomas Russ
In reply to this post by Tabbasum

On Jun 16, 2010, at 8:31 AM, Tabbasum Naz wrote:

> Hi,
>
> I am developing an ontology from a database.
> Database tables are represented as classes in ontology. Tables  
> fields are represented as properties in ontology.

Be aware that property names in OWL are global, unlike column names in  
a database schema that are scoped to a particular table.

Depending our your naming conventions, you may therefore, have a  
single property that is part of more than one table.  This will have  
an impact on the solution to the next question you have.

> I also want to store some information about primary and foreign keys  
> from database.
> Can anybody guide me how can I store primary key and foreign key  
> information in an ontology?

1) If each column truly has a unique property name, even if it has the  
same column name as column in another table:
    a) you could use an AnnotationProperty to attach that information  
to the Property
    b) you could use a meta class for that property

2) If columns with the same name in different tables are represented  
by the same property:
    You would need to create your own objects for storing the key  
information.
    Something like a PrimaryKey object that would identify the table  
class and the column property.
          PrimaryKey
              hasColumn <columnProperty>
              onTable <tableClass>
    Note that this will put you into OWL-Full, because you are using  
classes and properties as the values of properties.





_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Primary and Foreign Key Info in Ontology?

Matthew Horridge
Hi Tabbasum,

OWL 2 suports keys.  You can specify a list of properties (object properties and data properties) that make up the key and also specify the class whose instances the key will apply to.  This could be of use to you if you're dealing with instances.

Cheers,

Matthew


On 16 Jun 2010, at 19:38, Thomas Russ wrote:

>
> On Jun 16, 2010, at 8:31 AM, Tabbasum Naz wrote:
>
>> Hi,
>>
>> I am developing an ontology from a database.
>> Database tables are represented as classes in ontology. Tables fields are represented as properties in ontology.
>
> Be aware that property names in OWL are global, unlike column names in a database schema that are scoped to a particular table.
>
> Depending our your naming conventions, you may therefore, have a single property that is part of more than one table.  This will have an impact on the solution to the next question you have.
>
>> I also want to store some information about primary and foreign keys from database.
>> Can anybody guide me how can I store primary key and foreign key information in an ontology?
>
> 1) If each column truly has a unique property name, even if it has the same column name as column in another table:
>   a) you could use an AnnotationProperty to attach that information to the Property
>   b) you could use a meta class for that property
>
> 2) If columns with the same name in different tables are represented by the same property:
>   You would need to create your own objects for storing the key information.
>   Something like a PrimaryKey object that would identify the table class and the column property.
>         PrimaryKey
>             hasColumn <columnProperty>
>             onTable <tableClass>
>   Note that this will put you into OWL-Full, because you are using classes and properties as the values of properties.
>
>
>
>
>
> _______________________________________________
> protege-owl mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-owl
>
> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Primary and Foreign Key Info in Ontology?

Tabbasum
In reply to this post by Thomas Russ
Thanks Thomas, Martin and Matthew for your reply.
I want to remain in OWL DL.

Thomas has mentioned that it is possible through Annotation Property but I am not getting how I can use AnnotationProperty for this purpose. Is it possible that you can guide me through example.

I have developed a short example for this purpose with two Classes.
Class1: Personal
Properties: ID, Name and Nationality
ID is primary key in Personal.

Class2: Salary
Properties: ID, Currency and Duration.
ID is foreign key in Salary.

I am attaching owl file. Can you please guide me in the owl file example that how can i represent in ontology that ID is primary key for Personal table and foreign key for Salary table.

I'll be really thankful.
Regards
Tabbasum







From: Thomas Russ <[hidden email]>
To: User support for the Protege-OWL editor <[hidden email]>
Sent: Wed, June 16, 2010 7:38:34 PM
Subject: Re: [protege-owl] Primary and Foreign Key Info in Ontology?


On Jun 16, 2010, at 8:31 AM, Tabbasum Naz wrote:

> Hi,
>
> I am developing an ontology from a database.
> Database tables are represented as classes in ontology. Tables fields are represented as properties in ontology.

Be aware that property names in OWL are global, unlike column names in a database schema that are scoped to a particular table.

Depending our your naming conventions, you may therefore, have a single property that is part of more than one table.  This will have an impact on the solution to the next question you have.

> I also want to store some information about primary and foreign keys from database.
> Can anybody guide me how can I store primary key and foreign key information in an ontology?

1) If each column truly has a unique property name, even if it has the same column name as column in another table:
  a) you could use an AnnotationProperty to attach that information to the Property
  b) you could use a meta class for that property

2) If columns with the same name in different tables are represented by the same property:
  You would need to create your own objects for storing the key information.
  Something like a PrimaryKey object that would identify the table class and the column property.
        PrimaryKey
            hasColumn <columnProperty>
            onTable <tableClass>
  Note that this will put you into OWL-Full, because you are using classes and properties as the values of properties.





_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03

TryingPFKeys.owl (2K) Download Attachment
TryingPFKeys.pprj (250K) Download Attachment
TryingPFKeys.repository (38 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Primary and Foreign Key Info in Ontology?

Thomas Russ

On Jun 17, 2010, at 5:25 AM, Tabbasum Naz wrote:

> Thanks Thomas, Martin and Matthew for your reply.
> I want to remain in OWL DL.
>
> Thomas has mentioned that it is possible through Annotation Property  
> but I am not getting how I can use AnnotationProperty for this  
> purpose. Is it possible that you can guide me through example.
>
> I have developed a short example for this purpose with two Classes.
> Class1: Personal
> Properties: ID, Name and Nationality
> ID is primary key in Personal.
>
> Class2: Salary
> Properties: ID, Currency and Duration.
> ID is foreign key in Salary.
>
> I am attaching owl file. Can you please guide me in the owl file  
> example that how can i represent in ontology that ID is primary key  
> for Personal table and foreign key for Salary table.

I don't think you can do this in OWL DL if you name the columns  
globally.  That is because any annotation that you use on the property  
ID applies to the property itself and not to the property in the  
context of just a single table.

What you would need to do is make sure that each column has its own  
unique property ID.  You can keep the names the same by using  
rdfs:label or some other annotation property of your own creation.

So, doing something like this:

   Class: Personal
          restrictions associating Prop1, Prop2, Prop3 with class  
Personal.
          this might include making Personal the domain of the  
properties.
   Property: Prop1
             rdfs:label "ID"
             isPrimaryKey true
   Property: Prop2
             rdfs:label "Name"
   Property: Prop3
             rdfs:label "Nationality"


   Class: Salary
          properties Prop4, Prop5, Prop6
   Property: Prop4
             rdfs:label "ID"
             isForeignKey true
   Property: Prop5
             rdfs:label "Salary"
   Property: Prop6
             rdfs:label "Duration"

If you want to be complete, and since you do have complete knowledge,  
you could also add annotions:

   Prop1  isForeignKey false
   Prop2  isPrimaryKey false, isForeignKey false
   etc.





_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Primary and Foreign Key Info in Ontology?

Tabbasum
Dear Thomas,

I am really thankful to you for your valuable suggestions.
I am getting how to proceed further. Now situation becomes as below.

Class1: Personal
 Properties: PID, PName and PNationality (with corresponding Annotation Property:labels ID, Name and Nationality)

Class2: Salary
 Properties: SID, SCurrency and SDuration (with corresponding Annotation Property:labels ID, Currency and Duration)

isPrimaryKey and isForeignKey are Annotation Datatype properties of boolean type.

I have done it and attached the OWL file.
I am able to save information that SID and PID are primary key or foreign keys but
now question is how can I save information with SID property that it is linked to the Personal Class (Foreign key from Personal table). There will be multiple tables in future and i want to store the relavent table name for every foreign key as well.

Regards
Tabbasum



From: Thomas Russ <[hidden email]>
To: User support for the Protege-OWL editor <[hidden email]>
Sent: Thu, June 17, 2010 5:05:59 PM
Subject: Re: [protege-owl] Primary and Foreign Key Info in Ontology?


On Jun 17, 2010, at 5:25 AM, Tabbasum Naz wrote:

> Thanks Thomas, Martin and Matthew for your reply.
> I want to remain in OWL DL.
>
> Thomas has mentioned that it is possible through Annotation Property but I am not getting how I can use AnnotationProperty for this purpose. Is it possible that you can guide me through example.
>
> I have developed a short example for this purpose with two Classes.
> Class1: Personal
> Properties: ID, Name and Nationality
> ID is primary key in Personal.
>
> Class2: Salary
> Properties: ID, Currency and Duration.
> ID is foreign key in Salary.
>
> I am attaching owl file. Can you please guide me in the owl file example that how can i represent in ontology that ID is primary key for Personal table and foreign key for Salary table.

I don't think you can do this in OWL DL if you name the columns globally.  That is because any annotation that you use on the property ID applies to the property itself and not to the property in the context of just a single table.

What you would need to do is make sure that each column has its own unique property ID.  You can keep the names the same by using rdfs:label or some other annotation property of your own creation.

So, doing something like this:

  Class: Personal
        restrictions associating Prop1, Prop2, Prop3 with class Personal.
        this might include making Personal the domain of the properties.
  Property: Prop1
            rdfs:label "ID"
            isPrimaryKey true
  Property: Prop2
            rdfs:label "Name"
  Property: Prop3
            rdfs:label "Nationality"


  Class: Salary
        properties Prop4, Prop5, Prop6
  Property: Prop4
            rdfs:label "ID"
            isForeignKey true
  Property: Prop5
            rdfs:label "Salary"
  Property: Prop6
            rdfs:label "Duration"

If you want to be complete, and since you do have complete knowledge, you could also add annotions:

  Prop1  isForeignKey false
  Prop2  isPrimaryKey false, isForeignKey false
  etc.





_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03

TryingPFKeys.owl (4K) Download Attachment
TryingPFKeys.pprj (239K) Download Attachment
TryingPFKeys.repository (38 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Primary and Foreign Key Info in Ontology?

Thomas Russ

On Jun 17, 2010, at 10:30 AM, Tabbasum Naz wrote:

> now question is how can I save information with SID property that it  
> is linked to the Personal Class (Foreign key from Personal table).  
> There will be multiple tables in future and i want to store the  
> relavent table name for every foreign key as well.

Instead of using a Datatype Annotation property, use an Object  
Annotation Property and create an object (individual) with the  
information that you require.

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Primary and Foreign Key Info in Ontology?

Tabbasum
Thanks Thomas. It is helpful.

Regards
Tabbasum


From: Thomas Russ <[hidden email]>
To: User support for the Protege-OWL editor <[hidden email]>
Sent: Fri, June 18, 2010 12:10:44 AM
Subject: Re: [protege-owl] Primary and Foreign Key Info in Ontology?


On Jun 17, 2010, at 10:30 AM, Tabbasum Naz wrote:

> now question is how can I save information with SID property that it is linked to the Personal Class (Foreign key from Personal table). There will be multiple tables in future and i want to store the relavent table name for every foreign key as well.

Instead of using a Datatype Annotation property, use an Object Annotation Property and create an object (individual) with the information that you require.

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Primary and Foreign Key Info in Ontology?

Nick Khamis
That's database talk!

On Fri, Jun 18, 2010 at 6:46 AM, Tabbasum Naz <[hidden email]> wrote:
Thanks Thomas. It is helpful.

Regards
Tabbasum


From: Thomas Russ <[hidden email]>
To: User support for the Protege-OWL editor <[hidden email]>
Sent: Fri, June 18, 2010 12:10:44 AM
Subject: Re: [protege-owl] Primary and Foreign Key Info in Ontology?


On Jun 17, 2010, at 10:30 AM, Tabbasum Naz wrote:

> now question is how can I save information with SID property that it is linked to the Personal Class (Foreign key from Personal table). There will be multiple tables in future and i want to store the relavent table name for every foreign key as well.

Instead of using a Datatype Annotation property, use an Object Annotation Property and create an object (individual) with the information that you require.

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03



_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Primary and Foreign Key by using Mata Class in Ontology?

Tabbasum
In reply to this post by Thomas Russ
Hi,

If I use metaclasses to store the primary and foreign key information (I guess as done in DataMaster) then I'll be in OWL-DL or OWL-FULL?

This time I tried to store the information by meta-classes.
I created a class ForeignKey that has following properties.
Object Type:
linkedToRefColumn with Range owlDataType Property
linkedToRefTable with Range rdfs:Class
localColum Range owlDataType Property
localTable with Range rdfs:Class

DataType Property:
hasFKName with Range String

AnnotationObject Property:
hasForeignKey

For ForeignKey Class, I create an Individual that contains information about links between tables and cloumns.
And finally this individual is linked to a particular column name (SID in this example).
Is it a correct way of doing this? Doing this way, Am I still in OWL-DL?
I am also attaching owl file.

Regards
Tabbasum




From: Thomas Russ <[hidden email]>
To: User support for the Protege-OWL editor <[hidden email]>
Sent: Wed, June 16, 2010 7:38:34 PM
Subject: Re: [protege-owl] Primary and Foreign Key Info in Ontology?


On Jun 16, 2010, at 8:31 AM, Tabbasum Naz wrote:

> Hi,
>
> I am developing an ontology from a database.
> Database tables are represented as classes in ontology. Tables fields are represented as properties in ontology.

Be aware that property names in OWL are global, unlike column names in a database schema that are scoped to a particular table.

Depending our your naming conventions, you may therefore, have a single property that is part of more than one table.  This will have an impact on the solution to the next question you have.

> I also want to store some information about primary and foreign keys from database.
> Can anybody guide me how can I store primary key and foreign key information in an ontology?

1) If each column truly has a unique property name, even if it has the same column name as column in another table:
  a) you could use an AnnotationProperty to attach that information to the Property
  b) you could use a meta class for that property

2) If columns with the same name in different tables are represented by the same property:
  You would need to create your own objects for storing the key information.
  Something like a PrimaryKey object that would identify the table class and the column property.
        PrimaryKey
            hasColumn <columnProperty>
            onTable <tableClass>
  Note that this will put you into OWL-Full, because you are using classes and properties as the values of properties.





_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03

TryingMetaClass.owl (5K) Download Attachment
TryingMetaClass.pprj (235K) Download Attachment
TryingMetaClass.repository (38 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Primary and Foreign Key by using Mata Class in Ontology?

Thomas Russ

On Jun 18, 2010, at 5:05 AM, Tabbasum Naz wrote:

> Hi,
>
> If I use metaclasses to store the primary and foreign key  
> information (I guess as done in DataMaster) then I'll be in OWL-DL  
> or OWL-FULL?

OWL Full.

Any time you have a Class or Property as the range of a Property, then  
you will be in OWL Full.  (Except for certain built-in relations like  
subClassOf, etc.)

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Primary and Foreign Key by using Mata Class in Ontology?

Tabbasum
Okey, Thanks!


From: Thomas Russ <[hidden email]>
To: User support for the Protege-OWL editor <[hidden email]>
Sent: Fri, June 18, 2010 5:22:09 PM
Subject: Re: [protege-owl] Primary and Foreign Key by using Mata Class in Ontology?


On Jun 18, 2010, at 5:05 AM, Tabbasum Naz wrote:

> Hi,
>
> If I use metaclasses to store the primary and foreign key information (I guess as done in DataMaster) then I'll be in OWL-DL or OWL-FULL?

OWL Full.

Any time you have a Class or Property as the range of a Property, then you will be in OWL Full.  (Except for certain built-in relations like subClassOf, etc.)

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03