This SPARQL update query reconstructs links between sample assessment records after publishing or removing data. It first deletes existing "replaces" and "isReplacedBy" links. It then inserts new links, finding an update record and predecessor based on replacement/withdrawal status and date. It ensures there is no sample between the update and predecessor.
Convert to study materialsBETA
Transform any presentation into ready-made study materialselect from outputs like summaries, definitions, and practice questions.
3. our vision
a better
place for
people and
wildlife
to achieve this we will
Act to reduce Work with
Protect and Work with people
climate change businesses and other
improve water, and communities to
and its organisations to use
land and air create better places
consequences resources wisely
Be the best we
can
We cannot do this alone. We work closely with a wide range of
partners including government, business, local authorities, other
agencies, civil society groups and the communities we serve.
4. how we used to supply data
EA hosted web services
(and very restricted access to the actual data)
data supplies &
information requests
6. bathing water quality
start of season
Press interest
15th May
bathing season
20-22 samples
what information in 22weeks
is relevant to the public
about beaches 30th Sept
annual report
November
what
we do December
11. Tenby
Tourist Information Centre
Unit 2 , The Gateway Complex
Tenby. Wales , SA70 7LT
Tel: 01834 842 402
Fax: 01834 845 439
Email: tenby.tic@pembrokeshire.gov.uk
Photo by Skellig2008 (flickr)
12. Day 1 Day 1-3 Day 4
entered onto monitoring /
operational database
Sampling happens Lab analysis happens
Tuesday (snapshot)
available via data.gov.uk
Bathing Water
Weekly/Daily
assessment run
available on WIYBY
Linked data
feeds available on EyeOnEarth
available on our own apps
available on other apps
13. more than just linked data
api configuration *
applications
update process
data modelling
additional data
mini apps
* api as organised URI space
with consistent behaviours documentation others apps
16. URIs + Governance
Stable points of reference
Applications
Operational Data
Domain
Reference Data
Vocabularies
Standard
Vocabularies (RDF, RDFS, OWL)
Vocabularies and Reference Data form the foundations
Image from Wikimedia Commons CC-BY-2.5
17. "Cool URI's don't change" but...
http://www.w3.org/Provider/Style/URI
Stakeholder URI Sets
Sector Governance
education school
transport station
environment bathing-water
... ...
http://{sector}.data.gov.uk/id/{concept}/{reference}
thematic code-point
id things
doc documents about things <- reference data
data datasets and data items
INSPIRE
def vocabularies and terms
so spatial object
Infrastructure for Spatial Information in
the European Community
19. Modelling
Access to Domain Expertise (not just data)
Linkage to Legislation (terms and definitions)
Entities and Relationships
Lifecycles
Mutable and Invariant Properties
Sameness and difference
What do things mean?
eg. Assessment Criteria
Code lists (G,I,F,C,N what do these mean?)
21. Scaling Up
Update Server
Load
Balancers
SPARQL Update
Upload
Preview /
Convert
Review
Publish /
Remove
(Disposable)
Publishing
Backup / Restore Server x N
22. Encouraging Use and Reuse
RESTful API
http://environment.data.gov.uk/id/bathing-water/ukc2102-03600
http://environment.data.gov.uk/id/bathing-water
SELECT ?item
View Control WHERE { ... }
&view= selector Data
&_property={properties} GET /doc/bathing-water Store
&_metadata= +
viewer
DESCRIBE SPARQL
Page Control <x> <y> ... <z> Endpoint
&page= formatter
Formatted Response
&pageSize=
'native' linked data RDF Endpoint
semantic web TTL
Filtering
CSV
&{property}={value} Publication Server
'Developer friendly' XML config
&min-{property}={value} (elda+fuseki+jena)
JSON
&max-{property}={value}
Styled data for people HTML
Misc.
&_sort=
&_lang={langTags}
&callback= (for JSONP) Apache Jena
33. SPARQL Update Query (part 1 of 3)
preamble and delete
# SPARQL update query to patch up store after a publish or remove
PREFIX qb: <http://purl.org/linked-data/cube#>
PREFIX bwq: <http://environment.data.gov.uk/def/bathing-water-quality/>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX interval: <http://reference.data.gov.uk/def/intervals/>
# Remove previous replaces/replacedBy links for records
DELETE {
?update dct:replaces ?predecessor .
?predecessor dct:isReplacedBy ?update . }
WHERE {
?update dct:replaces ?predecessor .
?predecessor dct:isReplacedBy ?update . } ;
34. SPARQL Update Query (part 2 of 3)
insert: find an update record and its predecessors
# Reconstruct links based on current replacements/withdrawals
INSERT {
?update dct:replaces ?predecessor .
?predecessor dct:isReplacedBy ?update . }
WHERE {
?update a bwq:SampleAssessment;
bwq:bathingWater ?bw;
bwq:samplingPoint ?sp;
bwq:sampleDateTime ?u_stime ;
bwq:recordDate ?u_recordDate;
{ ?update bwq:recordStatus ?bwq:withdrawal }
UNION
{ ?update bwq:recordStatus ?bwq:replacement }
# Find a ?prececessor
?predecessor a bwq:SampleAssessment;
bwq:bathingWater ?bw;
bwq:samplingPoint ?sp;
bwq:sampleDateTime ?u_stime;
bwq:recordDate ?pred_recordDate;
.
FILTER (?pred_recordDate<?u_recordDate)
35. SPARQL Update Query (part 3 of 3)
insert: ensure there is no matching ?probe between ?update and ?predecessor
# Make sure that the is no ?probe between ?update and its immediate
# predecessor.
OPTIONAL {
?probe a bwq:SampleAssessment;
bwq:bathingWater ?bw;
bwq:samplingPoint ?sp;
bwq:sampleDateTime ?u_stime;
bwq:recordDate ?probe_recordDate;
FILTER ( ?probe_recordDate > ?pred_recordDate &&
?u_recordDate > ?probe_recordDate)
} FILTER (!bound(?probe))
} ;
Editor's Notes
#4: Our reason for being here is to help create a better place for people and wildlife.Increasingly we seek to achieve this by working closely with and/or influencing a wide range of others including businesses, government, local authorities, other agencies, civil society groups, communities and individuals getting them to use our information is critical in this.To help them to use our information when we share it requires us to provide it in ways that allow it to be useful, usable and to be built upon. This in turn will further its reach and influence in achieving our environmental outcomes.Critically our remit rightly puts those environmental outcomes first and everything else fits around that core aim
#7: Context about bathing water qualityWe get a lot of interest about bathing water quality, every year there are press articles and lots of information requests. We make our information available through are websiteThe public are interested in lots of things about beachesButOur remit is limited So we need to make our information available in ways that it can be combined with others
#8: Demo visualisation to show Incremental publication (able to do updates ourselves) Extend and adding scalability plus api documentation to support developers and enhanced application
#12: ContextWe have information about where we sample, the defined beach, the water quality results, other influencing things such as outflow pointsBut also of interest would be access, car parking, toilets, can you walk your dog, fishing rights, photos, history and so on
#14: Repurpose information that was previously locked up