SolidLabResearch / Challenges

24 stars 0 forks source link

Simplify adding, editing and deleting triples in data sources #129

Open AronBuzogany opened 6 months ago

AronBuzogany commented 6 months ago

Simplify adding, editing and deleting triples in data sources

Pitch

Many applications use the same form of query for querying, adding, removing and editing queries. As of right now every single one of these actions can require a long chain of synchronous function. With comunica:

This has to be done for every action to the datasource.

For example a list of friends:

PREFIX foaf: <http://xmlns.com/foaf/0.1/>

SELECT ?friend ?friendName ?friendDOB
WHERE {
  ?person foaf:knows ?friend ;

  ?friend foaf:name ?friendName ;
          foaf:birthday ?friendDOB .
}

We can add another friend by

PREFIX foaf: <http://xmlns.com/foaf/0.1/>

INSERT DATA {
  <http://example.org/person1> foaf:knows <http://example.org/friend2> .
  <http://example.org/friend2> foaf:name "Friend Two" ;
                             foaf:birthday "1990-01-01"^^<http://www.w3.org/2001/XMLSchema#date> .
}

The only thing we didn't know for this query where the name, webID and DOB . The structure and ontology used can all be extracted from the first query.

Same for deleting a friend:

PREFIX foaf: <http://xmlns.com/foaf/0.1/>

DELETE {
  <http://example.org/person1> foaf:knows  <http://example.org/person2> ;
  <http://example.org/person2> foaf:name "Friend's Name" ;
          foaf:birthday "1990-01-01"^^<http://www.w3.org/2001/XMLSchema#date> . 
}

Where the only additional thing we need is the triple from the first query we wish to remove.

This scenario, which is a reoccurring scenario, can be simplified for developers. Often this is a collection of data in one source (additional info might be needed from other sources e.g. fetch the name from webID.)

Desired solution

Create a class/object that's constructed by a query. This class/object then queries for the results (e.g. with comunica), streams the results in a certain form e.g. {id, result}.

This object can than parse the query it got constructed with and use the id to implement the following functions:

QueryHelper obj = new QueryHelper("select ?name ?dob where....");
obj.get(offset, limit);
obj.deleteTriple(id);
obj.addTriple(jsonObject); // where the json object has the same form as result 
obj.editTriple(id, jsonObject) ;

Acceptance criteria

The class/object working for the example in the pitch.

Pointers