import the tuples of a database as instance of a class

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

import the tuples of a database as instance of a class

shreyes

I am using the Datamaster tab in Protege 3.4.4.

I have created an ontology where the classes are plot_id, owner_name, area and landuse.

I have defined restrictions and relationships between them.

I have a database in mysql which has a table called as plots and it has 4 attributes.(plot_id, owner_name, area, landuse)

I created sub tables out of the plots table which consists of plot_id as the primary key in all the sub tables i.e. the tables are (plot_id,owner_name) ; (plot_id,area) ; (plot_id, landuse) so that i have a table for each of the classes i have created and they are related since they have plot_id in comman.

Now i want to import the tuples of the database as instance of the classes. i.e. for class plot_id i want the tuples of the plots table to be the instances, for class owner_name i want the tuples of the table which consists of the attributes (plot_id,owner_name), and so on.

Can you please tell me which option to choose from your datamaster tab.

Is this a proper thing that i am doing ?

After doing this i have to write swrl rules and then to retrieve i have write sqwrl queries.

Please help me.

 

Thank you


--
shreyes shiv
email: [hidden email]
phone: 9557975780
IIRS(Indian Institute of Remote Sensing)
No. 4, Kalidas Road, Dehradun-248001, Uttarakhand, India

_______________________________________________
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: import the tuples of a database as instance of a class

Timothy Redmond

I don't have a lot of experience with data master but it looks like you just need to set the database driver, url and login parameters, select the table that you want to import, decide if you want to import the table content and click import.

What problem are you having with data master?

-Timothy


On 03/07/2011 01:54 PM, shreyes shiv wrote:

I am using the Datamaster tab in Protege 3.4.4.

I have created an ontology where the classes are plot_id, owner_name, area and landuse.

I have defined restrictions and relationships between them.

I have a database in mysql which has a table called as plots and it has 4 attributes.(plot_id, owner_name, area, landuse)

I created sub tables out of the plots table which consists of plot_id as the primary key in all the sub tables i.e. the tables are (plot_id,owner_name) ; (plot_id,area) ; (plot_id, landuse) so that i have a table for each of the classes i have created and they are related since they have plot_id in comman.

Now i want to import the tuples of the database as instance of the classes. i.e. for class plot_id i want the tuples of the plots table to be the instances, for class owner_name i want the tuples of the table which consists of the attributes (plot_id,owner_name), and so on.

Can you please tell me which option to choose from your datamaster tab.

Is this a proper thing that i am doing ?

After doing this i have to write swrl rules and then to retrieve i have write sqwrl queries.

Please help me.

 

Thank you


--
shreyes shiv
email: [hidden email]
phone: 9557975780
IIRS(Indian Institute of Remote Sensing)
No. 4, Kalidas Road, Dehradun-248001, Uttarakhand, India
_______________________________________________ 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: import the tuples of a database as instance of a class

Csongor Nyulas
Administrator
In reply to this post by shreyes
Hi Shreyes,

I see 2 options for you:

Option 1
: You can keep the "plots" table as it is, and import its content as instances in your ontology, using DataMaster.

In this case, there will be only one class corresponding to the one table in the database, and each column will become an OWL datatype property.
Each row in the plots table will become an instance of the Plot class and you can write SWRL queries of the form
Plot(?p) ∧ area(?p, ?area) ∧ swrlb:lessThanOrEqual(?area, 27) →  Tax(tax_slab1)


Option 2: You can try to normalize your database, by creating separate tables to represent land use (and possibly also the owner) and you would import the content of your database as instances of multiple classes, using DataMaster.

Suppose you restructure your database as follows:
    plots (plot_id <PK> , hasOwner <FK> , area , hasLanduse <FK>)
    owner (owner_id <PK>, owner_name)
    landuse (landuse_id <PK>, landuse)
and you create all the primary keys (PKs) and foreign keys (FKs) that reference the PKs.
In this case, you will have 3 imported classes (or 2 if you decide that there is no point in extracting the owner in a separate table), one for each table.
"plot_id", "area", "owner_name" and "landuse" will become datatype properties, while "owner_id" and "landuse_id" will become object properties referencing instances from the Owner and Landuse classes.
You will be able to write SWRL queries of the form:
Plot(?p) ∧ hasLanduse(?p, ?lu) ∧ Landuse(?lu) ∧ landuse(?lu, ?landuse_descr) ∧ swrlb:equal(?landuse_descr, "private") ∧ area(?p, ?area) ∧ swrlb:lessThanOrEqual(?area, 27) →  Tax(tax_slab1)

Please note:
1. In both solution I did not created a separate table for the area (i.e. I did not want to instantiate the area) because I think that area should be really represented as a number, since each plot can have different value for its area, and it does not make sense to instantiate every possible number that represent an area.

2. In both solution you will need to use the following DataMaster options:
        Import tables as: classes
        Import table content: TRUE

I hope this helps you started,
Csongor

On 3/7/2011 1:54 PM, shreyes shiv wrote:

I am using the Datamaster tab in Protege 3.4.4.

I have created an ontology where the classes are plot_id, owner_name, area and landuse.

I have defined restrictions and relationships between them.

I have a database in mysql which has a table called as plots and it has 4 attributes.(plot_id, owner_name, area, landuse)

I created sub tables out of the plots table which consists of plot_id as the primary key in all the sub tables i.e. the tables are (plot_id,owner_name) ; (plot_id,area) ; (plot_id, landuse) so that i have a table for each of the classes i have created and they are related since they have plot_id in comman.

Now i want to import the tuples of the database as instance of the classes. i.e. for class plot_id i want the tuples of the plots table to be the instances, for class owner_name i want the tuples of the table which consists of the attributes (plot_id,owner_name), and so on.

Can you please tell me which option to choose from your datamaster tab.

Is this a proper thing that i am doing ?

After doing this i have to write swrl rules and then to retrieve i have write sqwrl queries.

Please help me.

 

Thank you


--
shreyes shiv
email: [hidden email]
phone: 9557975780
IIRS(Indian Institute of Remote Sensing)
No. 4, Kalidas Road, Dehradun-248001, Uttarakhand, India
_______________________________________________ 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: import the tuples of a database as instance of a class

shreyes
I got your suggestion right and it is working for me.
thank you

by writing a rule like
plot(?p) ∧ db:area(?p, ?area) ∧ swrlb:lessThanOrEqual(?area, 40.0) → sqwrl:select(?p, ?area)
I will get the plots and the corresponding area which are lesser than 40.0

I have a class called as Tax in the same ontology.
i have 4 sub classes called as tax_slab1, tax_slab2,tax_slab3 and tax_slab4.
Now i want to assign the plots which are the resultant of the above query to tax_slab1.
i.e. if i run the above rule then it should say that the plots belong to tax_slab1

how do i do this.
Reply | Threaded
Open this post in threaded view
|

Re: import the tuples of a database as instance of a class

Thomas Russ

On Mar 9, 2011, at 11:11 PM, shreyes wrote:

> I got your suggestion right and it is working for me.
> thank you
>
> by writing a rule like
> plot(?p) ∧ db:area(?p, ?area) ∧ swrlb:lessThanOrEqual(?area,  
> 40.0) →
> sqwrl:select(?p, ?area)
> I will get the plots and the corresponding area which are lesser  
> than 40.0
>
> I have a class called as Tax in the same ontology.
> i have 4 sub classes called as tax_slab1, tax_slab2,tax_slab3 and  
> tax_slab4.
> Now i want to assign the plots which are the resultant of the above  
> query to
> tax_slab1.
> i.e. if i run the above rule then it should say that the plots  
> belong to
> tax_slab1
>
> how do i do this.

I would expect that you replace

    sqwrl:select(?p, ?area)

with
     tax_slab1(?p)

If you are using OWL 2 and Protege 4.1 you can even write a direct OWL  
class definition that will classify the plots into the appropriate  
categories by using data range restrictions.  This will require that  
db:area be a FunctionalProperty.


_______________________________________________
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: import the tuples of a database as instance of a class

shreyes
Dr. Thomas

I wrote the following query

Plot(?p) ∧ db:Owner_nm(?p, ?own) ∧ db:Plot_id(?p, ?pl) ∧ db:Landuse(?p, ?land) ∧  swrlb:lessThanOrEqual(?a, 27.0) ∧ db:Area(?p, ?a) →  tax_slab1(?p)

But how do i know that the following instances have been assigned to tax_slab1 ?
Reply | Threaded
Open this post in threaded view
|

Re: import the tuples of a database as instance of a class

Martin O'Connor
On 3/10/2011 9:14 PM, shreyes wrote:
> I wrote the following query
>
> Plot(?p) ∧ db:Owner_nm(?p, ?own) ∧ db:Plot_id(?p, ?pl) ∧ db:Landuse(?p,
> ?land) ∧  swrlb:lessThanOrEqual(?a, 27.0) ∧ db:Area(?p, ?a) →  tax_slab1(?p)
>
> But how do i know that the following instances have been assigned to
> tax_slab1 ?
This is a rule, not a query.

A SQWRL query to examine tax_slab1 individuals can be written:

tax_slab1(?t) -> sqwrl:select(?t)

In general, SQWRL queries can be used to examine the results of SWRL rule execution.

cf. http://protege.cim3.net/cgi-bin/wiki.pl?SWRLLanguageFAQ#nidBEA

Martin


_______________________________________________
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