Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
AronBuzogany opened this issue Dec 21, 2023 · 0 comments
Open

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

AronBuzogany opened this issue Dec 21, 2023 · 0 comments
Assignees
Labels
challenge technical problem applied to a use case proposal: pending ❓

Comments

@AronBuzogany
Copy link

AronBuzogany commented Dec 21, 2023

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:

  • create a query engine
  • create a string query
  • use the engine to query
  • (optionally) get quad/bindingStream from result
  • register listeners/convert results to array.

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.

  • The class/object can be constructed with a query
  • We can do pagination with the .get function.
  • We can remove a triple with the id without having to create another string query.
  • We can add a triple without having to create another string query.

Pointers

Scenarios

@AronBuzogany AronBuzogany added challenge technical problem applied to a use case proposal: pending ❓ labels Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
challenge technical problem applied to a use case proposal: pending ❓
Projects
None yet
Development

No branches or pull requests

2 participants