Skip to content

Commit 5226710

Browse files
committed
Implemented recommended fixes
1 parent 631096b commit 5226710

5 files changed

Lines changed: 122 additions & 144 deletions

File tree

documentation/user-guides/design-patterns/Design Pattern 1/facility location/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ To represent location relationships where material entities (e.g., facilities, e
1313

1414
# Structure
1515

16-
Represents the location of a site and their appropriate relations with a broader area.
16+
Represents sites as locations and use of the located_in relation.
1717

18-
Helps with creating transitive relations between sites.
18+
Helps with show how non-transitive relation can be used to do a query that acts transitively.
1919

2020
Visual model through mermaid and png.
2121

documentation/user-guides/design-patterns/Design Pattern 1/facility location/sparql/CQ1.sparql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# CQ1: Where is a specific facility located?
1+
# CQ1: Where is a facility located?
22
# Returns the immediate site(s) where a given facility is located
33

44
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

documentation/user-guides/design-patterns/Design Pattern 1/facility location/sparql/CQ2.sparql

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,26 @@
22
# that the facility is also located in that are within the bigger site?
33
# Uses property paths to find the full location hierarchy
44

5-
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
6-
PREFIX cco: <https://www.commoncoreontologies.org/>
7-
PREFIX obo: <http://purl.obolibrary.org/obo/>
8-
PREFIX facility: <https://www.commoncoreontologies.org/ont00000192>
5+
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
6+
PREFIX cco: <https://www.commoncoreontologies.org/>
7+
PREFIX obo: <http://purl.obolibrary.org/obo/>
8+
PREFIX facility: <https://www.commoncoreontologies.org/ont00000192>
99
PREFIX located_in: <http://purl.obolibrary.org/obo/BFO_0000171>
1010

11-
SELECT ?facility ?facilityLabel ?immediateSite ?immediateSiteLabel ?largerSite ?largerSiteLabel
11+
SELECT ?site ?siteLabel ?parentSite ?parentSiteLabel
12+
(COUNT(?intermediate) AS ?depth)
1213
WHERE {
13-
?facility a facility: ;
14-
rdfs:label ?facilityLabel ;
15-
located_in: ?immediateSite .
16-
?immediateSite rdfs:label ?immediateSiteLabel ;
17-
located_in:+ ?largerSite .
18-
?largerSite rdfs:label ?largerSiteLabel .
14+
?site located_in: ?parentSite .
15+
?site rdfs:label ?siteLabel .
16+
?parentSite rdfs:label ?parentSiteLabel .
17+
18+
OPTIONAL { ?site a facility: }
19+
20+
OPTIONAL {
21+
?site located_in:+ ?intermediate .
22+
?intermediate located_in:+ ?parentSite .
23+
}
24+
1925
}
20-
ORDER BY ?facility ?largerSite
26+
GROUP BY ?site ?siteLabel ?parentSite ?parentSiteLabel
27+
ORDER BY ASC(?depth) ASC(?siteLabel)
Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
1-
# CQ3: What are all the facilities located within a particular site?
1+
# CQ3: What are all the facilities located within a site?
22
# Finds facilities directly or transitively located within a site
33

4-
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
5-
PREFIX cco: <https://www.commoncoreontologies.org/>
6-
PREFIX obo: <http://purl.obolibrary.org/obo/>
7-
PREFIX site: <http://purl.obolibrary.org/obo/BFO_0000029>
8-
PREFIX facility: <https://www.commoncoreontologies.org/ont00000192>
4+
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
5+
PREFIX cco: <https://www.commoncoreontologies.org/>
6+
PREFIX obo: <http://purl.obolibrary.org/obo/>
7+
PREFIX site: <http://purl.obolibrary.org/obo/BFO_0000029>
8+
PREFIX facility: <https://www.commoncoreontologies.org/ont00000192>
99
PREFIX located_in: <http://purl.obolibrary.org/obo/BFO_0000171>
1010

11-
SELECT ?site ?siteLabel ?facility ?facilityLabel
11+
SELECT ?targetSite ?targetSiteLabel ?facility ?facilityLabel
1212
WHERE {
13-
?site a site: ;
14-
rdfs:label ?siteLabel .
13+
14+
# ── Parameter: bind the site IRI you want to query ──────────────────────
15+
#BIND(<YOUR_SITE_IRI_HERE> AS ?targetSite)
16+
17+
BIND(<https://www.commoncoreontologies.org/CommonCoreOntologiesMerged/campus_manhattan> AS ?targetSite)
18+
19+
?targetSite rdfs:label ?targetSiteLabel .
20+
1521
?facility a facility: ;
1622
rdfs:label ?facilityLabel ;
17-
located_in:+ ?site .
23+
located_in:+ ?targetSite .
24+
1825
}
19-
ORDER BY ?site ?facility
26+
ORDER BY ASC(?facilityLabel)
27+
Lines changed: 81 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -1,138 +1,101 @@
1-
@prefix : <https://www.commoncoreontologies.org/CommonCoreOntologiesMerged/> .
2-
@prefix cco: <https://www.commoncoreontologies.org/> .
3-
@prefix obo: <http://purl.obolibrary.org/obo/> .
4-
@prefix owl: <http://www.w3.org/2002/07/owl#> .
5-
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
1+
# Test data for CQ1–CQ3
2+
# Imports CCO (which in turn imports BFO), so no need to restate definitions here.
3+
# For reference, the key classes and properties used are:
4+
# - obo:BFO_0000029 (site) — a three-dimensional immaterial entity
5+
# - cco:ont00000192 (Facility) — a Material Artifact dedicated to a specific purpose
6+
# - obo:BFO_0000171 (located in) — occupies a spatial region that is part of another's region
7+
# Full definitions are in the imported ontologies.
8+
9+
@prefix : <https://www.commoncoreontologies.org/CommonCoreOntologiesMerged/> .
10+
@prefix cco: <https://www.commoncoreontologies.org/> .
11+
@prefix obo: <http://purl.obolibrary.org/obo/> .
12+
@prefix owl: <http://www.w3.org/2002/07/owl#> .
13+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
614
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
7-
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
8-
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
9-
@prefix dc: <http://purl.org/dc/elements/1.1/> .
15+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
1016

11-
#################################################################
12-
# Object Properties
13-
#################################################################
14-
15-
### http://purl.obolibrary.org/obo/BFO_0000171
16-
obo:BFO_0000171 rdf:type owl:ObjectProperty ;
17-
dc:identifier "234-BFO" ;
18-
rdfs:label "located in"@en ;
19-
skos:definition "b located in c =Def b is an independent continuant & c is an independent & neither is a spatial region & there is some time t such that the spatial region which b occupies at t is continuant part of the spatial region which c occupies at t"@en ;
20-
skos:scopeNote "Users that require more sophisticated representations of time are encouraged to import a temporal extension of BFO-Core provided by the BFO development team."@en .
17+
<https://www.commoncoreontologies.org/CommonCoreOntologiesMerged/>
18+
rdf:type owl:Ontology ;
19+
owl:imports <https://www.commoncoreontologies.org/> .
2120

2221
#################################################################
23-
# Classes
24-
#################################################################
25-
26-
### http://purl.obolibrary.org/obo/BFO_0000029
27-
obo:BFO_0000029 rdf:type owl:Class ;
28-
dc:identifier "034-BFO" ;
29-
rdfs:label "site"@en ;
30-
skos:definition "(Elucidation) A site is a three-dimensional immaterial entity whose boundaries either (partially or wholly) coincide with the boundaries of one or more material entities or have locations determined in relation to some material entity"@en ;
31-
skos:example "A hole in a portion of cheese; a rabbit hole; the Grand Canyon; the Piazza San Marco; the kangaroo-joey-containing hole of a kangaroo pouch; your left nostril (a fiat part - the opening - of your left nasal cavity); the lumen of your gut; the hold of a ship; the interior of the trunk of your car; hole in an engineered floor joist"@en .
32-
33-
### https://www.commoncoreontologies.org/ont00000192
34-
cco:ont00000192 rdf:type owl:Class ;
35-
rdfs:label "Facility"@en ;
36-
skos:definition "A Material Artifact that is designed as a building or campus dedicated to some specific purpose."@en ;
37-
cco:ont00001760 "https://www.commoncoreontologies.org/ArtifactOntology"^^xsd:anyURI .
38-
39-
#################################################################
40-
# Individuals - Sites (Hierarchy)
22+
# Sites — location hierarchy (largest → smallest)
23+
#
24+
# NY State
25+
# └── New York City (located_in NY State)
26+
# │ └── Manhattan Campus (located_in NYC)
27+
# │ ├── Tower 1 (located_in Manhattan Campus)
28+
# │ └── Tower 2 (located_in Manhattan Campus)
29+
# └── Buffalo (located_in NY State)
30+
# California
31+
# └── Los Angeles (located_in California)
32+
# └── Downtown LA Campus (located_in LA)
33+
# Texas
34+
# └── Houston (located_in Texas)
4135
#################################################################
4236

4337
# States
44-
:state_ny rdf:type owl:NamedIndividual ,
45-
obo:BFO_0000029 ;
46-
rdfs:label "NY State" .
38+
:state_ny rdf:type obo:BFO_0000029 ; rdfs:label "NY State" .
39+
:state_ca rdf:type obo:BFO_0000029 ; rdfs:label "California" .
40+
:state_tx rdf:type obo:BFO_0000029 ; rdfs:label "Texas" .
4741

48-
:state_ca rdf:type owl:NamedIndividual ,
49-
obo:BFO_0000029 ;
50-
rdfs:label "California" .
42+
# Cities
43+
:city_nyc rdf:type obo:BFO_0000029 ; rdfs:label "New York City" ;
44+
obo:BFO_0000171 :state_ny . # NYC located_in NY State
5145

52-
:state_tx rdf:type owl:NamedIndividual ,
53-
obo:BFO_0000029 ;
54-
rdfs:label "Texas" .
46+
:city_buffalo rdf:type obo:BFO_0000029 ; rdfs:label "Buffalo" ;
47+
obo:BFO_0000171 :state_ny . # Buffalo located_in NY State
5548

56-
# Cities
57-
:city_nyc rdf:type owl:NamedIndividual ,
58-
obo:BFO_0000029 ;
59-
rdfs:label "New York City" ;
60-
obo:BFO_0000171 :state_ny .
61-
62-
:city_buffalo rdf:type owl:NamedIndividual ,
63-
obo:BFO_0000029 ;
64-
rdfs:label "Buffalo" ;
65-
obo:BFO_0000171 :state_ny .
66-
67-
:city_la rdf:type owl:NamedIndividual ,
68-
obo:BFO_0000029 ;
69-
rdfs:label "Los Angeles" ;
70-
obo:BFO_0000171 :state_ca .
71-
72-
:city_houston rdf:type owl:NamedIndividual ,
73-
obo:BFO_0000029 ;
74-
rdfs:label "Houston" ;
75-
obo:BFO_0000171 :state_tx .
49+
:city_la rdf:type obo:BFO_0000029 ; rdfs:label "Los Angeles" ;
50+
obo:BFO_0000171 :state_ca . # LA located_in California
51+
52+
:city_houston rdf:type obo:BFO_0000029 ; rdfs:label "Houston" ;
53+
obo:BFO_0000171 :state_tx . # Houston located_in Texas
7654

7755
# Campuses
78-
:campus_manhattan rdf:type owl:NamedIndividual ,
79-
obo:BFO_0000029 ;
80-
rdfs:label "Manhattan Campus" ;
81-
obo:BFO_0000171 :city_nyc .
56+
:campus_manhattan rdf:type obo:BFO_0000029 ; rdfs:label "Manhattan Campus" ;
57+
obo:BFO_0000171 :city_nyc . # Manhattan Campus located_in NYC
8258

83-
:campus_downtown_la rdf:type owl:NamedIndividual ,
84-
obo:BFO_0000029 ;
85-
rdfs:label "Downtown LA Campus" ;
86-
obo:BFO_0000171 :city_la .
59+
:campus_downtown_la rdf:type obo:BFO_0000029 ; rdfs:label "Downtown LA Campus" ;
60+
obo:BFO_0000171 :city_la . # Downtown LA Campus located_in LA
8761

8862
# Buildings
89-
:building_tower1 rdf:type owl:NamedIndividual ,
90-
obo:BFO_0000029 ;
91-
rdfs:label "Tower 1" ;
92-
obo:BFO_0000171 :campus_manhattan .
63+
:building_tower1 rdf:type obo:BFO_0000029 ; rdfs:label "Tower 1" ;
64+
obo:BFO_0000171 :campus_manhattan . # Tower 1 located_in Manhattan Campus
9365

94-
:building_tower2 rdf:type owl:NamedIndividual ,
95-
obo:BFO_0000029 ;
96-
rdfs:label "Tower 2" ;
97-
obo:BFO_0000171 :campus_manhattan .
66+
:building_tower2 rdf:type obo:BFO_0000029 ; rdfs:label "Tower 2" ;
67+
obo:BFO_0000171 :campus_manhattan . # Tower 2 located_in Manhattan Campus
9868

9969
#################################################################
100-
# Individuals - Facilities
70+
# Facilities
71+
#
72+
# NYC Main Warehouse located_in Tower 1
73+
# NYC Corporate Office located_in Tower 2
74+
# NYC Research Lab located_in Manhattan Campus
75+
# Buffalo Distribution Ctr located_in Buffalo
76+
# LA Warehouse located_in Downtown LA Campus
77+
# LA Regional Office located_in Los Angeles
78+
# Houston Manufacturing located_in Houston
10179
#################################################################
10280

103-
:facility_warehouse_nyc rdf:type owl:NamedIndividual ,
104-
cco:ont00000192 ;
105-
rdfs:label "NYC Main Warehouse" ;
106-
obo:BFO_0000171 :building_tower1 .
107-
108-
:facility_office_nyc rdf:type owl:NamedIndividual ,
109-
cco:ont00000192 ;
110-
rdfs:label "NYC Corporate Office" ;
111-
obo:BFO_0000171 :building_tower2 .
112-
113-
:facility_lab_nyc rdf:type owl:NamedIndividual ,
114-
cco:ont00000192 ;
115-
rdfs:label "NYC Research Lab" ;
116-
obo:BFO_0000171 :campus_manhattan .
117-
118-
:facility_warehouse_buffalo rdf:type owl:NamedIndividual ,
119-
cco:ont00000192 ;
120-
rdfs:label "Buffalo Distribution Center" ;
121-
obo:BFO_0000171 :city_buffalo .
122-
123-
:facility_warehouse_la rdf:type owl:NamedIndividual ,
124-
cco:ont00000192 ;
125-
rdfs:label "LA Warehouse" ;
126-
obo:BFO_0000171 :campus_downtown_la .
127-
128-
:facility_office_la rdf:type owl:NamedIndividual ,
129-
cco:ont00000192 ;
130-
rdfs:label "LA Regional Office" ;
131-
obo:BFO_0000171 :city_la .
132-
133-
:facility_plant_houston rdf:type owl:NamedIndividual ,
134-
cco:ont00000192 ;
135-
rdfs:label "Houston Manufacturing Plant" ;
136-
obo:BFO_0000171 :city_houston .
137-
138-
81+
:facility_warehouse_nyc rdf:type cco:ont00000192 ; rdfs:label "NYC Main Warehouse" ;
82+
obo:BFO_0000171 :building_tower1 . # → Tower 1
83+
84+
:facility_office_nyc rdf:type cco:ont00000192 ; rdfs:label "NYC Corporate Office" ;
85+
obo:BFO_0000171 :building_tower2 . # → Tower 2
86+
87+
:facility_lab_nyc rdf:type cco:ont00000192 ; rdfs:label "NYC Research Lab" ;
88+
obo:BFO_0000171 :campus_manhattan . # → Manhattan Campus
89+
90+
:facility_warehouse_buffalo rdf:type cco:ont00000192 ; rdfs:label "Buffalo Distribution Center" ;
91+
obo:BFO_0000171 :city_buffalo . # → Buffalo
92+
93+
:facility_warehouse_la rdf:type cco:ont00000192 ; rdfs:label "LA Warehouse" ;
94+
obo:BFO_0000171 :campus_downtown_la . # → Downtown LA Campus
95+
96+
:facility_office_la rdf:type cco:ont00000192 ; rdfs:label "LA Regional Office" ;
97+
obo:BFO_0000171 :city_la . # → Los Angeles
98+
99+
:facility_plant_houston rdf:type cco:ont00000192 ; rdfs:label "Houston Manufacturing Plant" ;
100+
obo:BFO_0000171 :city_houston . # → Houston
101+

0 commit comments

Comments
 (0)