| Status | Subtype | Assigned | Task | ||
|---|---|---|---|---|---|
| Resolved | Hjfocs | T169985 Implement the Curation API | |||
| Resolved | Hjfocs | T169986 Find how to mark the state of data in the back-end |
Event Timeline
Comment Actions
Experimenting 2 solutions:
- add a state triple to each relevant node, i.e., subject, statement, qualifier, reference;
- use state named graphs and store data accordingly.
Both solutions require an update query made by the front-end to change the state upon approval or rejection.
Comment Actions
State triple solution experiment.
Input dataset, Turtle format, named graph http://chuck-berry
@prefix wd: <http://www.wikidata.org/entity/> . @prefix wds: <http://www.wikidata.org/entity/statement/> . @prefix wdref: <http://www.wikidata.org/reference/> . @prefix p: <http://www.wikidata.org/prop/> . @prefix ps: <http://www.wikidata.org/prop/statement/> . @prefix pq: <http://www.wikidata.org/prop/qualifier/> . @prefix pr: <http://www.wikidata.org/prop/reference/> . @prefix prov: <http://www.w3.org/ns/prov#> . wd:Q5921 p:P18 wds:Q5921-583C7277-B344-4C96-8CF2-0557C2D0CD34 . wds:Q5921-583C7277-B344-4C96-8CF2-0557C2D0CD34 ps:P18 <http://commons.wikimedia.org/wiki/Special:FilePath/Chuck-berry-2007-07-18.jpg> ; pq:P2096 "Chuck Berry (2007)"@ca ; prov:wasDerivedFrom wdref:288ab581e7d2d02995a26dfa8b091d96e78457fc . wdref:288ab581e7d2d02995a26dfa8b091d96e78457fc pr:P143 wd:Q206855 .
State triples to be added at upload time (into the same named graph http://chuck-berry)
# Claim wd:Q5921 <http://www.wikidata.org/primary-sources/state> "new" . # Reference wdref:288ab581e7d2d02995a26dfa8b091d96e78457fc <http://www.wikidata.org/primary-sources/state> "new" . # Qualifier pq:P2096 <http://www.wikidata.org/primary-sources/state> "new" .
Given the Chuck Berry Item Q5921, the front end must run the following query to retrieve the data
PREFIX pst: <http://www.wikidata.org/primary-sources/>
SELECT ?property ?statement_property ?statement_value ?reference_property ?reference_value
WHERE {
GRAPH <http://chuck-berry> {
# Claim
wd:Q5921 pst:state "new" ;
?property ?statement .
?statement ?statement_property ?statement_value .
# Qualifier
OPTIONAL {
?statement_property pst:state "new" .
}
# Reference
OPTIONAL {
?statement_value pst:state "new" ;
?reference_property ?reference_value .
}
}
}The front end must run the following update queries, depending on which part of the statement.
On claim approval
PREFIX pst: <http://www.wikidata.org/primary-sources/>
WITH <http://chuck-berry>
DELETE {
wd:Q5921 pst:state "new" .
?statement_property pst:state "new" .
?statement_value pst:state "new" .
}
INSERT {
wd:Q5921 pst:state "approved" .
?statement_property pst:state "approved" .
?statement_value pst:state "approved" .
}
WHERE {
wd:Q5921 pst:state "new" ;
?property ?statement .
?statement ?statement_property ?statement_value .
OPTIONAL {
?statement_property pst:state "new" .
}
OPTIONAL {
?statement_value pst:state "new" .
}
}On qualifier approval
PREFIX pst: <http://www.wikidata.org/primary-sources/>
WITH <http://chuck-berry>
DELETE {
?statement_property pst:state "new" .
}
INSERT {
?statement_property pst:state "approved" .
}
WHERE {
wd:Q5921 pst:state "new" ;
?property ?statement .
?statement ?statement_property ?statement_value .
?statement_property pst:state "new" .
}On reference approval
PREFIX pst: <http://www.wikidata.org/primary-sources/>
WITH <http://chuck-berry>
DELETE {
?statement_value pst:state "new" .
}
INSERT {
?statement_value pst:state "approved" .
}
WHERE {
wd:Q5921 pst:state "new" ;
?property ?statement .
?statement ?statement_property ?statement_value .
?statement_value pst:state "new" .
}Notes
- storage overhead in terms of additional state triples;
- relatively complex queries to both retrieve the data and to update;
- since full values for qualifiers seem to be required only for complex data types, they should be mostly represented by simple values. Hence, the state triple must be attached to a predicate, instead of a subject, e.g., pq:P2096 <http://www.wikidata.org/primary-sources/state> "new" .
Comment Actions
State named graphs solution experiment.
The input dataset is the same as above, but the named graph http://chuck-berry/new is minted at upload time.
On data retrieval
SELECT ?property ?statement_property ?statement_value ?reference_property ?reference_value
WHERE {
GRAPH <http://chuck-berry/new> {
# Claim
wd:Q5921 ?property ?statement .
# Qualifier
?statement ?statement_property ?statement_value .
# Reference
OPTIONAL {
?statement_value ?reference_property ?reference_value .
}
}
}On claim approval
DELETE {
GRAPH <http://chuck-berry/new> {
wd:Q5921 ?property ?statement .
?statement ?statement_property ?statement_value .
?statement_value ?reference_property ?reference_value .
}
}
INSERT {
GRAPH <http://chuck-berry/approved> {
wd:Q5921 ?property ?statement .
?statement ?statement_property ?statement_value .
?statement_value ?reference_property ?reference_value .
}
}
WHERE {
wd:Q5921 ?property ?statement .
?statement ?statement_property ?statement_value .
OPTIONAL {
?statement_value ?reference_property ?reference_value .
}
}On qualifier approval
DELETE {
GRAPH <http://chuck-berry/new> {
?statement pq:P2096 ?statement_value .
}
}
INSERT {
GRAPH <http://chuck-berry/approved> {
?statement pq:P2096 ?statement_value .
}
}
WHERE {
wd:Q5921 ?property ?statement .
?statement pq:P2096 ?statement_value .
}On reference approval
DELETE {
GRAPH <http://chuck-berry/new> {
?statement_value pr:P143 ?reference_value .
}
}
INSERT {
GRAPH <http://chuck-berry/approved> {
?statement_value pr:P143 ?reference_value .
}
}
WHERE {
wd:Q5921 ?property ?statement .
?statement ?statement_property ?statement_value .
?statement_value pr:P143 ?reference_value .
}Notes
- no additional triples needed;
- quite easy queries to retrieve and update the data;
- explicit triples grouping based on the state;
- not trivial to get all new datasets.