├── .gitignore
├── LICENSE
├── README.md
├── bi-sql
├── README.md
└── music_table_mappings.ttl
├── getting-started
├── GettingStarted_Movie_Schema.ttl.gz
├── GettingStarted_Movie_data.ttl.gz
└── GettingStarted_Music_Data.ttl.gz
├── mappings
├── README.md
├── music_mappings.sms
├── music_mappings.ttl
└── music_mappings_r2rml.ttl
├── music
├── README.md
├── beatles.ttl
├── music.ttl.gz
└── music_schema.ttl
├── named-graphs
├── 01-create-graphs.sparql
├── 02-solo-artist-albums.sparql
├── 03-albums.sparql
└── 04-beatles-in-a-graph.sparql
├── reasoning
├── artists.sparql
├── cowriter-rule.ttl
├── mccartney-cowriters.sparql
└── music_axioms.ttl
├── shacl
├── invalid.ttl
├── music_shacl.ttl
└── valid.ttl
├── sparql
├── 01a-albums.sparql
├── 01b-albums.sparql
├── 02-albums-artists.sparql
├── 03-albums-solo-artists.sparql
├── 04a-albums-dates.sparql
├── 04b-albums-dates.sparql
├── 05-albums-dates-sorted.sparql
├── 06-albums-dates-limited.sparql
├── 07a-albums-dates-filtered.sparql
├── 07b-albums-dates-filtered.sparql
├── 07c-albums-dates-filtered.sparql
├── 08a-albums-years-duplicates.sparql
├── 08b-albums-years-distinct.sparql
├── 09-albums-dates.minmax.sparql
├── 10-albums-count.sparql
├── 11a-albums-dates-grouped.sparql
├── 11b-albums-duplicate-dates.sparql
├── 12-albums-dates-subselect.sparql
├── 13-artists-union.sparql
├── 14a-songs-length.sparql
├── 14b-songs-optional-length.sparql
├── 14c-songs-unbound-length.sparql
├── 14d-songs-no-length.sparql
├── 15a-cowriters.sparql
├── 15b-cowriters-sequence-path.sparql
├── 15c-cowriters-mccartney.sparql
├── 15d-cowriters-recursive-path.sparql
├── 15e-songs-optional-path.sparql
├── 15f-songs-alternative-path.sparql
├── 16a-cowriters-paths.sparql
├── 16b-cowriters-paths.sparql
├── 16c-cowriters-paths.sparql
├── 17-bands-writers-ask.sparql
├── 18a-beatles-describe.sparql
├── 18b-bands-describe.sparql
├── 19a-bands-construct.sparql
├── 19b-bands-members-construct.sparql
├── 20-bands-members-insert.sparql
└── 21-songs-length-delete.sparql
├── stardog-geospatial
└── dclandmarks.ttl
└── using-virtual-graphs
├── README.md
├── albums_by_year.sparql
├── artists.sparql
├── beatles.sql
├── beatles_members.sparql
├── beatles_members_birthdates.sparql
├── insert_birthdates.sparql
├── music.properties
└── music_schema.sql
/.gitignore:
--------------------------------------------------------------------------------
1 | *.DS_Store
2 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Stardog Tutorial data
2 |
3 | This repository contains data, mappings and queries referenced in [Stardog tutorials](https://www.stardog.com/tutorials/).
4 |
--------------------------------------------------------------------------------
/bi-sql/README.md:
--------------------------------------------------------------------------------
1 | # Table Mappings
2 |
3 | This example shows SQL table mappings to expose the RDF graph in a Stardog database as a SQL database via Stardog's
4 | built-in [BI/SQL](https://www.stardog.com/docs/#_business_intelligence_tools_and_sql_queries) server. The [mappings](music_table_mappings.ttl)
5 | here were [automatically generated](https://www.stardog.com/docs/#_auto_generated_schema_mappings) from the [SHACL constraints](../shacl/music_shacl.ttl)
6 | using the [`data model`](https://www.stardog.com/docs/man/data-model) command.
7 |
8 |
--------------------------------------------------------------------------------
/bi-sql/music_table_mappings.ttl:
--------------------------------------------------------------------------------
1 | @prefix : .
2 | @prefix stardog: .
3 | @prefix owl: .
4 | @prefix rdf: .
5 | @prefix xsd: .
6 | @prefix rdfs: .
7 | @prefix sql: .
8 |
9 | :ArtistTableMapping a sql:TableMapping ;
10 | sql:tableName "Artist" ;
11 | sql:class :Artist ;
12 | sql:hasField [
13 | sql:property :name ;
14 | sql:fieldName "name" ;
15 | sql:type xsd:string
16 | ] .
17 |
18 | :AlbumTableMapping a sql:TableMapping ;
19 | sql:tableName "Album" ;
20 | sql:class :Album ;
21 | sql:hasField [
22 | sql:property :date ;
23 | sql:fieldName "date" ;
24 | sql:type xsd:date
25 | ] , [
26 | sql:property :artist ;
27 | sql:fieldName "artist" ;
28 | sql:refersTo :ArtistTableMapping
29 | ] , [
30 | sql:property :name ;
31 | sql:fieldName "name" ;
32 | sql:type xsd:string
33 | ] , [
34 | sql:property :track ;
35 | sql:fieldName "track" ;
36 | sql:refersTo :SongTableMapping
37 | ] .
38 |
39 | :SongTableMapping a sql:TableMapping ;
40 | sql:tableName "Song" ;
41 | sql:class :Song ;
42 | sql:hasField [
43 | sql:property :name ;
44 | sql:fieldName "name" ;
45 | sql:type xsd:string
46 | ] , [
47 | sql:property :length ;
48 | sql:fieldName "length" ;
49 | sql:type xsd:integer
50 | ] .
51 |
52 | :SoloArtistTableMapping a sql:TableMapping ;
53 | sql:tableName "SoloArtist" ;
54 | sql:class :SoloArtist .
55 |
56 | :BandTableMapping a sql:TableMapping ;
57 | sql:tableName "Band" ;
58 | sql:class :Band ;
59 | sql:hasField [
60 | sql:property :member ;
61 | sql:fieldName "member" ;
62 | sql:refersTo :SoloArtistTableMapping
63 | ] .
64 |
65 |
--------------------------------------------------------------------------------
/getting-started/GettingStarted_Movie_Schema.ttl.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stardog-union/stardog-tutorials/e61e9c9d0b1f66b48403a4b631ac814bb60ef411/getting-started/GettingStarted_Movie_Schema.ttl.gz
--------------------------------------------------------------------------------
/getting-started/GettingStarted_Movie_data.ttl.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stardog-union/stardog-tutorials/e61e9c9d0b1f66b48403a4b631ac814bb60ef411/getting-started/GettingStarted_Movie_data.ttl.gz
--------------------------------------------------------------------------------
/getting-started/GettingStarted_Music_Data.ttl.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stardog-union/stardog-tutorials/e61e9c9d0b1f66b48403a4b631ac814bb60ef411/getting-started/GettingStarted_Music_Data.ttl.gz
--------------------------------------------------------------------------------
/mappings/README.md:
--------------------------------------------------------------------------------
1 | # Virtual Graph Mappings
2 |
3 | Data that accompanies the [Virtual Graph Mappings](https://www.stardog.com/tutorials/data-mappings/) tutorial.
4 |
--------------------------------------------------------------------------------
/mappings/music_mappings.sms:
--------------------------------------------------------------------------------
1 | PREFIX :
2 |
3 | MAPPING :AlbumMapping
4 | FROM SQL {
5 | SELECT * FROM Album
6 | }
7 | TO {
8 | ?album a :Album ;
9 | :name ?name ;
10 | :artist ?artist ;
11 | :date ?release_date
12 | }
13 | WHERE {
14 | BIND(template("http://stardog.com/tutorial/Album{id}") AS ?album)
15 | BIND(template("http://stardog.com/tutorial/Artist{artist}") AS ?artist)
16 | };
17 |
18 | MAPPING :ArtistMapping
19 | FROM SQL {
20 | SELECT * FROM Artist
21 | }
22 | TO {
23 | ?artist :name ?name ;
24 | :description ?description
25 | }
26 | WHERE {
27 | BIND(template("http://stardog.com/tutorial/Artist{id}") AS ?artist)
28 | };
29 |
30 | MAPPING :SoloArtistMapping
31 | FROM SQL {
32 | SELECT * FROM Artist WHERE type = 1
33 | }
34 | TO {
35 | ?artist a :SoloArtist
36 | }
37 | WHERE {
38 | BIND(template("http://stardog.com/tutorial/Artist{id}") AS ?artist)
39 | };
40 |
41 | MAPPING :BandMapping
42 | FROM SQL {
43 | SELECT * FROM Artist WHERE type = 2
44 | }
45 | TO {
46 | ?artist a :Band
47 | }
48 | WHERE {
49 | BIND(template("http://stardog.com/tutorial/Artist{id}") AS ?artist)
50 | };
51 |
52 | MAPPING :MemberMapping
53 | FROM SQL {
54 | SELECT * FROM Membership
55 | }
56 | TO {
57 | ?band :member ?member
58 | }
59 | WHERE {
60 | BIND(template("http://stardog.com/tutorial/Artist{band}") AS ?band)
61 | BIND(template("http://stardog.com/tutorial/Artist{artist}") AS ?member)
62 | };
63 |
64 | MAPPING :SongMapping
65 | FROM SQL {
66 | SELECT * FROM Track
67 | }
68 | TO {
69 | ?song a :Song ;
70 | :name ?name ;
71 | :length ?length .
72 |
73 | ?album :track ?song .
74 | }
75 | WHERE {
76 | BIND(template("http://stardog.com/tutorial/Song{id}") AS ?song)
77 | BIND(template("http://stardog.com/tutorial/Album{album}") AS ?album)
78 | };
79 |
80 | MAPPING :SongwriterMapping
81 | FROM SQL {
82 | SELECT * FROM Songwriter
83 | }
84 | TO {
85 | ?song :writer ?writer
86 | }
87 | WHERE {
88 | BIND(template("http://stardog.com/tutorial/Song{song}") AS ?song)
89 | BIND(template("http://stardog.com/tutorial/Artist{writer}") AS ?writer)
90 | }
--------------------------------------------------------------------------------
/mappings/music_mappings.ttl:
--------------------------------------------------------------------------------
1 | PREFIX :
2 | PREFIX sm:
3 |
4 | :Album{id} a :Album ;
5 | :name "{name}" ;
6 | :date "{release_date}" ;
7 | :artist :Artist{artist} ;
8 | sm:map [ sm:table "Album" ] .
9 |
10 | :Artist{id} a :SoloArtist ;
11 | sm:map [ sm:query "SELECT id FROM Artist WHERE type = 1" ] .
12 |
13 | :Artist{id} a :Band ;
14 | sm:map [ sm:query "SELECT id FROM Artist WHERE type = 2" ] .
15 |
16 | :Artist{id} :name "{name}" ;
17 | :description "{description}" ;
18 | sm:map [ sm:table "Artist" ] .
19 |
20 | :Artist{artist} :member :Artist{band} ;
21 | sm:map [ sm:table "Membership" ] .
22 |
23 | :Song{id} a :Song ;
24 | :name "{name}" ;
25 | :length "{length}" ;
26 | sm:map [ sm:table "Track" ] .
27 |
28 | :Album{album} :track :Song{id} ;
29 | sm:map [ sm:table "Track" ] .
30 |
31 | :Song{song} :writer :Artist{writer} ;
32 | sm:map [ sm:table "Songwriter" ] .
--------------------------------------------------------------------------------
/mappings/music_mappings_r2rml.ttl:
--------------------------------------------------------------------------------
1 | prefix :
2 | prefix rr:
3 |
4 | :AlbumMapping
5 | a rr:TriplesMap ;
6 | rr:subjectMap [
7 | rr:template "http://stardog.com/tutorial/Album{id}" ;
8 | rr:class :Album
9 | ] ;
10 | rr:predicateObjectMap [
11 | rr:predicate :name ;
12 | rr:objectMap [ rr:column "name" ]
13 | ] ;
14 | rr:predicateObjectMap [
15 | rr:predicate :date ;
16 | rr:objectMap [ rr:column "release_date" ]
17 | ] ;
18 | rr:predicateObjectMap [
19 | rr:predicate :artist ;
20 | rr:objectMap [ rr:template "http://stardog.com/tutorial/Artist{artist}" ]
21 | ] ;
22 | rr:logicalTable [ rr:tableName "Album" ] .
23 |
24 | :SoloArtistMapping
25 | a rr:TriplesMap ;
26 | rr:subjectMap [
27 | rr:template "http://stardog.com/tutorial/Artist{id}" ;
28 | rr:class :SoloArtist
29 | ] ;
30 | rr:logicalTable [ rr:sqlQuery "SELECT id FROM Artist WHERE type = 1" ] .
31 |
32 | :BandMapping
33 | a rr:TriplesMap ;
34 | rr:subjectMap [
35 | rr:template "http://stardog.com/tutorial/Artist{id}" ;
36 | rr:class :Band
37 | ] ;
38 | rr:logicalTable [ rr:sqlQuery "SELECT id FROM Artist WHERE type = 2" ] .
39 |
40 | :ArtistMapping
41 | a rr:TriplesMap ;
42 | rr:subjectMap [
43 | rr:template "http://stardog.com/tutorial/Artist{id}"
44 | ] ;
45 | rr:predicateObjectMap [
46 | rr:predicate :name ;
47 | rr:objectMap [ rr:column "name" ]
48 | ] ;
49 | rr:predicateObjectMap [
50 | rr:predicate :description ;
51 | rr:objectMap [ rr:column "description" ]
52 | ] ;
53 | rr:logicalTable [ rr:tableName "Artist" ] .
54 |
55 |
56 | :MembershipMapping
57 | a rr:TriplesMap ;
58 | rr:subjectMap [
59 | rr:template "http://stardog.com/tutorial/Artist{id}"
60 | ] ;
61 | rr:predicateObjectMap [
62 | rr:predicate :name ;
63 | rr:objectMap [ rr:column "name" ]
64 | ] ;
65 | rr:predicateObjectMap [
66 | rr:predicate :description ;
67 | rr:objectMap [ rr:column "description" ]
68 | ] ;
69 | rr:logicalTable [ rr:tableName "Artist" ] .
70 |
71 | :SongMapping
72 | a rr:TriplesMap ;
73 | rr:subjectMap [
74 | rr:template "http://stardog.com/tutorial/Song{id}"
75 | ] ;
76 | rr:predicateObjectMap [
77 | rr:predicate :name ;
78 | rr:objectMap [ rr:column "name" ]
79 | ] ;
80 | rr:predicateObjectMap [
81 | rr:predicate :length ;
82 | rr:objectMap [ rr:column "length" ]
83 | ] ;
84 | rr:logicalTable [ rr:tableName "Track" ] .
85 |
86 | :SongAlbumMapping
87 | a rr:TriplesMap ;
88 | rr:subjectMap [
89 | rr:template "http://stardog.com/tutorial/Album{album}"
90 | ] ;
91 | rr:predicateObjectMap [
92 | rr:predicate :track ;
93 | rr:objectMap [ rr:template "http://stardog.com/tutorial/Song{id}" ]
94 | ] ;
95 | rr:logicalTable [ rr:tableName "Track" ] .
96 |
97 | :SongwriterMapping
98 | a rr:TriplesMap ;
99 | rr:subjectMap [
100 | rr:template "http://stardog.com/tutorial/Song{song}"
101 | ] ;
102 | rr:predicateObjectMap [
103 | rr:predicate :writer ;
104 | rr:objectMap [ rr:template "http://stardog.com/tutorial/Artist{writer}" ]
105 | ] ;
106 | rr:logicalTable [ rr:tableName "Songwriter" ] .
107 |
--------------------------------------------------------------------------------
/music/README.md:
--------------------------------------------------------------------------------
1 | # Music Dataset
2 |
3 | Music dataset used throughout the tutorials. The `music_schema.ttl` is a simple schema for the music dataset. The `beatles.ttl` is a tiny version of the dataset with only a handful triples. The `music.ttl.gz` is a small subset of the [DBpedia dataset](https://wiki.dbpedia.org) and have been simplified to use the simple schema we have. The DBpedia datasets are licensed under the terms of the [Creative Commons Attribution-ShareAlike License](http://creativecommons.org/licenses/by-sa/3.0/) and the [GNU Free Documentation License](http://www.gnu.org/copyleft/fdl.html).
4 |
--------------------------------------------------------------------------------
/music/beatles.ttl:
--------------------------------------------------------------------------------
1 | PREFIX :
2 | PREFIX rdf:
3 | PREFIX xsd:
4 |
5 | :The_Beatles rdf:type :Band .
6 | :The_Beatles :name "The Beatles" .
7 | :The_Beatles :member :John_Lennon .
8 | :The_Beatles :member :Paul_McCartney .
9 | :The_Beatles :member :Ringo_Starr .
10 | :The_Beatles :member :George_Harrison .
11 | :John_Lennon rdf:type :SoloArtist .
12 | :Paul_McCartney rdf:type :SoloArtist .
13 | :Ringo_Starr rdf:type :SoloArtist .
14 | :George_Harrison rdf:type :SoloArtist .
15 | :Please_Please_Me rdf:type :Album .
16 | :Please_Please_Me :name "Please Please Me" .
17 | :Please_Please_Me :date "1963-03-22"^^xsd:date .
18 | :Please_Please_Me :artist :The_Beatles .
19 | :Please_Please_Me :track :Love_Me_Do .
20 | :Love_Me_Do rdf:type :Song .
21 | :Love_Me_Do :name "Love Me Do" .
22 | :Love_Me_Do :length 125 .
23 | :Love_Me_Do :writer :John_Lennon .
24 | :Love_Me_Do :writer :Paul_McCartney .
25 |
26 | :McCartney rdf:type :Album .
27 | :McCartney :name "McCartney" .
28 | :McCartney :date "1970-04-17"^^xsd:date .
29 | :McCartney :artist :Paul_McCartney .
30 |
31 | :Imagine rdf:type :Album .
32 | :Imagine :name "Imagine" .
33 | :Imagine :date "1971-10-11"^^xsd:date .
34 | :Imagine :artist :John_Lennon .
--------------------------------------------------------------------------------
/music/music.ttl.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stardog-union/stardog-tutorials/e61e9c9d0b1f66b48403a4b631ac814bb60ef411/music/music.ttl.gz
--------------------------------------------------------------------------------
/music/music_schema.ttl:
--------------------------------------------------------------------------------
1 | PREFIX :
2 | PREFIX rdf:
3 | PREFIX rdfs:
4 | PREFIX xsd:
5 |
6 | :Person a rdfs:Class ;
7 | rdfs:label "Person" ;
8 | rdfs:comment "A person." .
9 |
10 | :Artist a rdfs:Class ;
11 | rdfs:label "Artist" ;
12 | rdfs:comment "A person or a group of people creating and performing music." .
13 |
14 | :Band a rdfs:Class ;
15 | rdfs:label "Band" ;
16 | rdfs:comment "A music group; that is, is a group of people creating and performing music together." ;
17 | rdfs:subClassOf :Artist .
18 |
19 | :SoloArtist a rdfs:Class ;
20 | rdfs:label "SoloArtist" ;
21 | rdfs:comment "A single person who is a musical artist." ;
22 | rdfs:subClassOf :Artist , :Person .
23 |
24 | :Album a rdfs:Class ;
25 | rdfs:label "Album" ;
26 | rdfs:comment "A collection of songs released by an artist on physical or digital medium." .
27 |
28 | :Song a rdfs:Class ;
29 | rdfs:label "Song" ;
30 | rdfs:comment "A music recording that is a single work of music." .
31 |
32 | :Songwriter a rdfs:Class ;
33 | rdfs:label "Songwriter" ;
34 | rdfs:comment "A person or a group of people who participated in the creation of song as a composer or a lyricist." ;
35 | rdfs:subClassOf :Person .
36 |
37 | :name a rdf:Property ;
38 | rdfs:label "name" ;
39 | rdfs:comment "The name of an entity." ;
40 | rdfs:range xsd:string .
41 |
42 | :member a rdf:Property ;
43 | rdfs:label "name" ;
44 | rdfs:comment "A member of a band. Does not distinguish between past vs current members." ;
45 | rdfs:domain :Band ;
46 | rdfs:range :SoloArtist .
47 |
48 | :date a rdf:Property ;
49 | rdfs:label "date" ;
50 | rdfs:comment "The release date of an album." ;
51 | rdfs:domain :Album ;
52 | rdfs:range xsd:date .
53 |
54 | :artist a rdf:Property ;
55 | rdfs:label "artist" ;
56 | rdfs:comment "The artist that performed this album." ;
57 | rdfs:domain :Album ;
58 | rdfs:range :Artist .
59 |
60 | :track a rdf:Property ;
61 | rdfs:label "track" ;
62 | rdfs:comment "A song included in an album." ;
63 | rdfs:domain :Album ;
64 | rdfs:range :Song .
65 |
66 | :writer a rdf:Property ;
67 | rdfs:label "writer" ;
68 | rdfs:comment "A person or a group of people who participated in the creation of song as a composer or a lyricist." ;
69 | rdfs:domain :Song ;
70 | rdfs:range :Songwriter .
71 |
72 | :length a rdf:Property ;
73 | rdfs:label "length" ;
74 | rdfs:comment "The length of a song in the album expressed in seconds." ;
75 | rdfs:domain :Song ;
76 | rdfs:range xsd:integer .
77 |
--------------------------------------------------------------------------------
/named-graphs/01-create-graphs.sparql:
--------------------------------------------------------------------------------
1 | DELETE {
2 | ?s ?p ?o
3 | }
4 | INSERT {
5 | GRAPH ?type {
6 | ?s ?p ?o
7 | }
8 | }
9 | WHERE {
10 | ?s a ?type ;
11 | ?p ?o
12 | VALUES ?type { :Album :Song }
13 | };
14 |
15 | MOVE DEFAULT TO :People
--------------------------------------------------------------------------------
/named-graphs/02-solo-artist-albums.sparql:
--------------------------------------------------------------------------------
1 | SELECT * {
2 | GRAPH :Album {
3 | ?album a :Album .
4 | ?album :artist ?artist .
5 | }
6 | GRAPH :People {
7 | ?artist a :SoloArtist .
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/named-graphs/03-albums.sparql:
--------------------------------------------------------------------------------
1 | SELECT *
2 | FROM :Album
3 | {
4 | ?album a :Album .
5 | ?album :artist ?artist .
6 | ?album :date ?date .
7 | }
8 |
--------------------------------------------------------------------------------
/named-graphs/04-beatles-in-a-graph.sparql:
--------------------------------------------------------------------------------
1 | SELECT * {
2 | GRAPH ?g {
3 | ?x a ?type ;
4 | :name "The Beatles" .
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/reasoning/artists.sparql:
--------------------------------------------------------------------------------
1 | SELECT * {
2 | ?artist a :Artist
3 | }
--------------------------------------------------------------------------------
/reasoning/cowriter-rule.ttl:
--------------------------------------------------------------------------------
1 | RULE :CowriterRule
2 | IF {
3 | ?song :writer ?artist .
4 | ?song :writer ?cowriter
5 | FILTER (?artist != ?cowriter)
6 | }
7 | THEN {
8 | ?artist :cowriter ?cowriter
9 | }
10 |
--------------------------------------------------------------------------------
/reasoning/mccartney-cowriters.sparql:
--------------------------------------------------------------------------------
1 | SELECT * {
2 | :Paul_McCartney :cowriter ?cowriter
3 | }
--------------------------------------------------------------------------------
/reasoning/music_axioms.ttl:
--------------------------------------------------------------------------------
1 | PREFIX :
2 |
3 | [] a owl:Ontology ;
4 | rdfs:description "This is a very simple ontology that enriches the base music schema with some example OWL axioms." .
5 |
6 | :writerOf owl:inverseOf :writer .
7 |
8 | :cowriter owl:propertyChainAxiom (:writerOf :writer) .
9 |
10 | :cowriter rdfs:subPropertyOf :connectedTo .
11 |
12 | :connectedTo a owl:TransitiveProperty .
13 |
14 | :connectedTo a owl:SymmetricProperty .
15 |
--------------------------------------------------------------------------------
/shacl/invalid.ttl:
--------------------------------------------------------------------------------
1 | PREFIX :
2 |
3 | :The_Beatles a :Band ;
4 | :name "The Beatles" ;
5 | :member :John_Lennon , :Paul_McCartney , :George_Harrison , :Ringo_Starr .
6 |
7 | :John_Lennon a :SoloArtist ;
8 | :name "John Lennon" .
9 |
10 | :Paul_McCartney a :SoloArtist ;
11 | :name "Paul McCartney" .
12 |
13 | :Ringo_Starr a :SoloArtist ;
14 | :name "Ringo Starr" .
15 |
16 | :George_Harrison a :SoloArtist ;
17 | :name "George Harrison" .
18 |
19 | :Please_Please_Me a :Album ;
20 | :name "Please Please Me" ;
21 | :date "1963-03-22"^^xsd:date , "1963-02-23"^^xsd:date ;
22 | :artist :The_Beatles ;
23 | :track :Love_Me_Do .
24 |
25 | :Love_Me_Do a :Song ;
26 | :name "Love Me Do" ;
27 | :length 125.0 ;
28 | :writer :John_Lennon , :Paul_McCartney .
29 |
30 | :McCartney a :Album ;
31 | :name "McCartney" ;
32 | :date "1970-04-17"^^xsd:date ;
33 | :artist :Paul_McCartney .
34 |
35 | :Imagine a :Album , :Song ;
36 | :name "Imagine" ;
37 | :date "1971"^^xsd:gYear ;
38 | :artist :John_Lennon ;
39 | :track :Imagine .
--------------------------------------------------------------------------------
/shacl/music_shacl.ttl:
--------------------------------------------------------------------------------
1 | PREFIX :
2 | PREFIX sh:
3 | PREFIX xsd:
4 |
5 | :NameShape a sh:NodeShape ;
6 | sh:property [
7 | sh:path :name ;
8 | sh:minCount 1 ;
9 | sh:datatype xsd:string
10 | ] .
11 |
12 | :ArtistShape a sh:NodeShape ;
13 | sh:targetClass :Artist ;
14 | sh:node :NameShape .
15 |
16 | :BandShape a sh:NodeShape ;
17 | sh:targetClass :Band ;
18 | sh:not [ sh:class :Person ] ;
19 | sh:property :BandMemberShape .
20 |
21 | :BandMemberShape a sh:PropertyShape ;
22 | sh:path :member ;
23 | sh:minCount 1 ;
24 | sh:class :SoloArtist .
25 |
26 | :AlbumShape a sh:NodeShape ;
27 | sh:targetClass :Album ;
28 | sh:node :NameShape ;
29 | sh:not [ sh:class :Song ] ;
30 | sh:property :AlbumDateShape ;
31 | sh:property :AlbumArtistShape ;
32 | sh:property :AlbumTrackShape .
33 |
34 | :AlbumDateShape a sh:PropertyShape ;
35 | sh:path :date ;
36 | sh:minCount 1 ;
37 | sh:maxCount 1 ;
38 | sh:datatype xsd:date .
39 |
40 | :AlbumArtistShape a sh:PropertyShape ;
41 | sh:path :artist ;
42 | sh:minCount 1 ;
43 | sh:class :Artist .
44 |
45 | :AlbumTrackShape a sh:PropertyShape ;
46 | sh:path :track ;
47 | sh:minCount 1 ;
48 | sh:class :Song .
49 |
50 | :SongShape a sh:NodeShape ;
51 | sh:targetClass :Song ;
52 | sh:node :NameShape ;
53 | sh:property :SongLengthShape .
54 |
55 | :SongLengthShape a sh:PropertyShape ;
56 | sh:path :length ;
57 | sh:datatype xsd:integer .
58 |
--------------------------------------------------------------------------------
/shacl/valid.ttl:
--------------------------------------------------------------------------------
1 | PREFIX :
2 |
3 | :The_Beatles a :Band ;
4 | :name "The Beatles" ;
5 | :member :John_Lennon , :Paul_McCartney , :George_Harrison , :Ringo_Starr .
6 |
7 | :John_Lennon a :SoloArtist ;
8 | :name "John Lennon" .
9 |
10 | :Paul_McCartney a :SoloArtist ;
11 | :name "Paul McCartney" .
12 |
13 | :Ringo_Starr a :SoloArtist ;
14 | :name "Ringo Starr" .
15 |
16 | :George_Harrison a :SoloArtist ;
17 | :name "George Harrison" .
18 |
19 | :Please_Please_Me a :Album ;
20 | :name "Please Please Me" ;
21 | :date "1963-03-22"^^xsd:date ;
22 | :artist :The_Beatles ;
23 | :track :Love_Me_Do .
24 |
25 | :Love_Me_Do a :Song ;
26 | :name "Love Me Do" ;
27 | :length 125 ;
28 | :writer :John_Lennon , :Paul_McCartney .
--------------------------------------------------------------------------------
/sparql/01a-albums.sparql:
--------------------------------------------------------------------------------
1 | SELECT ?album
2 | WHERE {
3 | ?album rdf:type :Album .
4 | }
5 |
--------------------------------------------------------------------------------
/sparql/01b-albums.sparql:
--------------------------------------------------------------------------------
1 | SELECT *
2 | {
3 | ?album a :Album
4 | }
5 |
--------------------------------------------------------------------------------
/sparql/02-albums-artists.sparql:
--------------------------------------------------------------------------------
1 | SELECT *
2 | {
3 | ?album a :Album .
4 | ?album :artist ?artist .
5 | }
6 |
--------------------------------------------------------------------------------
/sparql/03-albums-solo-artists.sparql:
--------------------------------------------------------------------------------
1 | SELECT *
2 | {
3 | ?album a :Album .
4 | ?album :artist ?artist .
5 | ?artist a :SoloArtist .
6 | }
7 |
--------------------------------------------------------------------------------
/sparql/04a-albums-dates.sparql:
--------------------------------------------------------------------------------
1 | SELECT *
2 | {
3 | ?album a :Album .
4 | ?album :artist ?artist .
5 | ?album :date ?date .
6 | }
7 |
--------------------------------------------------------------------------------
/sparql/04b-albums-dates.sparql:
--------------------------------------------------------------------------------
1 | SELECT *
2 | {
3 | ?album a :Album ;
4 | :artist ?artist ;
5 | :date ?date .
6 | }
7 |
--------------------------------------------------------------------------------
/sparql/05-albums-dates-sorted.sparql:
--------------------------------------------------------------------------------
1 | SELECT *
2 | {
3 | ?album a :Album ;
4 | :artist ?artist ;
5 | :date ?date
6 | }
7 | ORDER BY ?date
8 |
9 |
--------------------------------------------------------------------------------
/sparql/06-albums-dates-limited.sparql:
--------------------------------------------------------------------------------
1 | SELECT *
2 | {
3 | ?album a :Album ;
4 | :artist ?artist ;
5 | :date ?date
6 | }
7 | ORDER BY desc(?date)
8 | LIMIT 2
9 |
--------------------------------------------------------------------------------
/sparql/07a-albums-dates-filtered.sparql:
--------------------------------------------------------------------------------
1 | SELECT *
2 | {
3 | ?album a :Album ;
4 | :artist ?artist ;
5 | :date ?date
6 | FILTER (?date >= "1970-01-01"^^xsd:date)
7 | }
8 | ORDER BY ?date
--------------------------------------------------------------------------------
/sparql/07b-albums-dates-filtered.sparql:
--------------------------------------------------------------------------------
1 | SELECT *
2 | {
3 | ?album a :Album ;
4 | :artist ?artist ;
5 | :date ?date
6 | FILTER (year(?date) >= 1970)
7 | }
8 | ORDER BY ?date
--------------------------------------------------------------------------------
/sparql/07c-albums-dates-filtered.sparql:
--------------------------------------------------------------------------------
1 | SELECT *
2 | {
3 | ?album a :Album ;
4 | :artist ?artist ;
5 | :date ?date
6 | BIND (year(?date) AS ?year)
7 | FILTER (?year >= 1970)
8 | }
9 | ORDER BY ?date
--------------------------------------------------------------------------------
/sparql/08a-albums-years-duplicates.sparql:
--------------------------------------------------------------------------------
1 | SELECT ?year
2 | {
3 | ?album a :Album ;
4 | :artist ?artist ;
5 | :date ?date
6 | BIND (year(?date) AS ?year)
7 | }
8 | ORDER BY ?date
--------------------------------------------------------------------------------
/sparql/08b-albums-years-distinct.sparql:
--------------------------------------------------------------------------------
1 | SELECT DISTINCT ?year
2 | {
3 | ?album a :Album ;
4 | :artist ?artist ;
5 | :date ?date
6 | BIND (year(?date) AS ?year)
7 | }
8 | ORDER BY ?year
9 |
--------------------------------------------------------------------------------
/sparql/09-albums-dates.minmax.sparql:
--------------------------------------------------------------------------------
1 | SELECT (min(?date) as ?minDate) (max(?date) as ?maxDate)
2 | {
3 | ?album a :Album ;
4 | :date ?date
5 | }
--------------------------------------------------------------------------------
/sparql/10-albums-count.sparql:
--------------------------------------------------------------------------------
1 | SELECT (count(?album) as ?count)
2 | {
3 | ?album a :Album
4 | }
--------------------------------------------------------------------------------
/sparql/11a-albums-dates-grouped.sparql:
--------------------------------------------------------------------------------
1 | SELECT ?year (count(?album) AS ?count)
2 | {
3 | ?album a :Album ;
4 | :date ?date ;
5 | BIND (year(?date) AS ?year)
6 | }
7 | GROUP BY ?year
8 | ORDER BY desc(?count)
--------------------------------------------------------------------------------
/sparql/11b-albums-duplicate-dates.sparql:
--------------------------------------------------------------------------------
1 | SELECT ?album (group_concat(?date) AS ?dates)
2 | {
3 | ?album a :Album ;
4 | :date ?date
5 | }
6 | GROUP BY ?album
7 | HAVING (count(?date) > 1)
--------------------------------------------------------------------------------
/sparql/12-albums-dates-subselect.sparql:
--------------------------------------------------------------------------------
1 | SELECT (avg(?count) AS ?avgCount)
2 | {
3 | SELECT ?year (count(?album) AS ?count)
4 | {
5 | ?album a :Album ;
6 | :date ?date ;
7 | BIND (year(?date) AS ?year)
8 | }
9 | GROUP BY ?year
10 | }
--------------------------------------------------------------------------------
/sparql/13-artists-union.sparql:
--------------------------------------------------------------------------------
1 | SELECT ?name
2 | {
3 | { ?artist a :SoloArtist }
4 | UNION
5 | { ?artist a :Band }
6 | ?artist :name ?name
7 | }
--------------------------------------------------------------------------------
/sparql/14a-songs-length.sparql:
--------------------------------------------------------------------------------
1 | SELECT * {
2 | ?song a :Song .
3 | ?song :length ?length .
4 | }
--------------------------------------------------------------------------------
/sparql/14b-songs-optional-length.sparql:
--------------------------------------------------------------------------------
1 | SELECT ?song ?length {
2 | ?song a :Song .
3 | OPTIONAL {
4 | ?song :length ?length .
5 | }
6 | }
--------------------------------------------------------------------------------
/sparql/14c-songs-unbound-length.sparql:
--------------------------------------------------------------------------------
1 | SELECT ?song ?length {
2 | ?song a :Song .
3 | OPTIONAL {
4 | ?song :length ?length .
5 | }
6 | FILTER(!bound(?length))
7 | }
--------------------------------------------------------------------------------
/sparql/14d-songs-no-length.sparql:
--------------------------------------------------------------------------------
1 | SELECT ?song {
2 | ?song a :Song .
3 | FILTER NOT EXISTS {
4 | ?song :length ?length .
5 | }
6 | }
--------------------------------------------------------------------------------
/sparql/15a-cowriters.sparql:
--------------------------------------------------------------------------------
1 | select distinct ?artist ?cowriter
2 | {
3 | ?song :writer ?artist .
4 | ?song :writer ?cowriter
5 | FILTER (?artist != ?cowriter)
6 | }
--------------------------------------------------------------------------------
/sparql/15b-cowriters-sequence-path.sparql:
--------------------------------------------------------------------------------
1 | select distinct ?artist ?cowriter
2 | {
3 | ?artist ^:writer/:writer ?cowriter
4 | FILTER (?artist != ?cowriter)
5 | }
--------------------------------------------------------------------------------
/sparql/15c-cowriters-mccartney.sparql:
--------------------------------------------------------------------------------
1 | select distinct ?cowriter
2 | {
3 | :Paul_McCartney ^:writer/:writer ?cowriter
4 | FILTER (?cowriter != :Paul_McCartney)
5 | }
6 | order by ?cowriter
--------------------------------------------------------------------------------
/sparql/15d-cowriters-recursive-path.sparql:
--------------------------------------------------------------------------------
1 | select distinct ?cowriter
2 | {
3 | :Paul_McCartney (^:writer/:writer)+ ?cowriter
4 | FILTER (?cowriter != :Paul_McCartney)
5 | }
6 | order by ?cowriter
--------------------------------------------------------------------------------
/sparql/15e-songs-optional-path.sparql:
--------------------------------------------------------------------------------
1 | select ?album {
2 | ?album :artist/:member? :Paul_McCartney
3 | }
--------------------------------------------------------------------------------
/sparql/15f-songs-alternative-path.sparql:
--------------------------------------------------------------------------------
1 | select ?song {
2 | ?song (^:track/:artist/:member?)|:writer :Paul_McCartney
3 | }
--------------------------------------------------------------------------------
/sparql/16a-cowriters-paths.sparql:
--------------------------------------------------------------------------------
1 | paths
2 | start ?artist = :Paul_McCartney
3 | end ?cowriter
4 | via {
5 | ?artist ^:writer/:writer ?cowriter
6 | }
7 | order by ?cowriter
--------------------------------------------------------------------------------
/sparql/16b-cowriters-paths.sparql:
--------------------------------------------------------------------------------
1 | paths
2 | start ?artist = :Paul_McCartney
3 | end ?cowriter = :Kanye_West
4 | via {
5 | ?song :writer ?artist .
6 | ?song :writer ?cowriter
7 | }
--------------------------------------------------------------------------------
/sparql/16c-cowriters-paths.sparql:
--------------------------------------------------------------------------------
1 | paths
2 | start ?artist = "Paul McCartney"
3 | end ?cowriter = "Kanye West"
4 | via {
5 | ?song ^:name/:writer/:name ?artist .
6 | ?song ^:name/:writer/:name ?cowriter
7 | }
--------------------------------------------------------------------------------
/sparql/17-bands-writers-ask.sparql:
--------------------------------------------------------------------------------
1 | ASK {
2 | ?band a :Band .
3 | ?song :writer ?band .
4 | }
--------------------------------------------------------------------------------
/sparql/18a-beatles-describe.sparql:
--------------------------------------------------------------------------------
1 | PREFIX :
2 |
3 | DESCRIBE :The_Beatles
--------------------------------------------------------------------------------
/sparql/18b-bands-describe.sparql:
--------------------------------------------------------------------------------
1 | PREFIX :
2 |
3 | DESCRIBE ?band
4 | WHERE {
5 | ?band a :Band ;
6 | :name ?name
7 | FILTER(contains(?name, "The"))
8 | }
--------------------------------------------------------------------------------
/sparql/19a-bands-construct.sparql:
--------------------------------------------------------------------------------
1 | PREFIX :
2 |
3 | CONSTRUCT WHERE {
4 | ?band a :Band ;
5 | :member ?member
6 | }
--------------------------------------------------------------------------------
/sparql/19b-bands-members-construct.sparql:
--------------------------------------------------------------------------------
1 | PREFIX :
2 |
3 | CONSTRUCT {
4 | ?member a :BandMember
5 | }
6 | WHERE {
7 | ?band a :Band ;
8 | :member ?member
9 | }
--------------------------------------------------------------------------------
/sparql/20-bands-members-insert.sparql:
--------------------------------------------------------------------------------
1 | INSERT {
2 | ?member a :BandMember
3 | }
4 | WHERE {
5 | ?band a :Band ;
6 | :member ?member
7 | }
--------------------------------------------------------------------------------
/sparql/21-songs-length-delete.sparql:
--------------------------------------------------------------------------------
1 | DELETE {
2 | ?song :length ?seconds
3 | }
4 | INSERT {
5 | ?song :length ?duration
6 | }
7 | WHERE {
8 | ?song a :Song ;
9 | :length ?seconds
10 | BIND(?seconds * "PT1S"^^xsd:dayTimeDuration AS ?duration)
11 | }
--------------------------------------------------------------------------------
/stardog-geospatial/dclandmarks.ttl:
--------------------------------------------------------------------------------
1 | @prefix wgs: .
2 | @prefix geo: .
3 | @prefix geof: .
4 | @prefix unit: .
5 | @prefix ogc: .
6 | @prefix xsd: .
7 | @prefix : .
8 |
9 | :Pentagon a :Location ;
10 | rdfs:label "The Pentagon" ;
11 | geo:hasGeometry :PentagonGeom .
12 | :PentagonGeom a geo:Geometry ;
13 | geo:asWKT "Point(-77.05526 38.87095)"^^geo:wktLiteral.
14 |
15 | :TombOfUnknown a :Location ;
16 | rdfs:label "Tomb of the Unknown Soldier" ;
17 | geo:hasGeometry :TombOfUnknownGeom .
18 | :TombOfUnknownGeom a geo:Geometry ;
19 | geo:asWKT "Point(-77.0722 38.87622)"^^geo:wktLiteral .
20 |
21 | :JeffMem a :Location ;
22 | rdfs:label "Jefferson Memorial" ;
23 | geo:hasGeometry :JeffMemGeom .
24 | :JeffMemGeom a geo:Geometry ;
25 | geo:asWKT "Point(-77.03633 38.88101)"^^geo:wktLiteral .
26 |
27 | :LincolnMem a :Location ;
28 | rdfs:label "Lincoln Memorial" ;
29 | geo:hasGeometry :LincolnMemGeom .
30 | :LincolnMemGeom a geo:Geometry ;
31 | geo:asWKT "Point(-77.04998 38.88928)"^^geo:wktLiteral .
32 |
33 | :WashingtonMon a :Location ;
34 | rdfs:label "Washington Monument" ;
35 | geo:hasGeometry :WashingtonMonGeom .
36 | :WashingtonMonGeom a geo:Geometry ;
37 | geo:asWKT "Point(-77.03525 38.88956)"^^geo:wktLiteral .
38 |
39 | :Capitol a :Location ;
40 | rdfs:label "US Capitol Building" ;
41 | geo:hasGeometry :CapitolGeom .
42 | :CapitolGeom a geo:Geometry ;
43 | wgs:lat "38.88983"^^xsd:float ;
44 | wgs:long "-77.00887"^^xsd:float .
45 |
46 | :NatlMall a :Location ;
47 | rdfs:label "National Mall" ;
48 | geo:hasGeometry :NatlMallGeom .
49 | :NatlMallGeom a geo:Geometry ;
50 | wgs:lat "38.88956"^^xsd:float ;
51 | wgs:long "-77.02303"^^xsd:float .
52 |
53 | :NASAHQ a :Location ;
54 | rdfs:label "NASA Headquarters" ;
55 | geo:hasGeometry :NASAHQGeom .
56 | :NASAHQGeom a geo:Geometry ;
57 | wgs:lat "38.882929"^^xsd:float ;
58 | wgs:long "-77.016379"^^xsd:float .
59 |
60 | :VietnamMem a :Location ;
61 | rdfs:label "Vietnam Veterans' Memorial" ;
62 | geo:hasGeometry :VietnamMemGeom .
63 | :VietnamMemGeom a geo:Geometry ;
64 | wgs:lat "38.89095"^^xsd:float ;
65 | wgs:long "-77.04692"^^xsd:float .
66 |
67 | :WhiteHouse a :Location ;
68 | rdfs:label "The White House" ;
69 | geo:hasGeometry :WhiteHouseGeom .
70 | :WhiteHouseGeom a geo:Geometry ;
71 | wgs:lat "38.89761"^^xsd:float ;
72 | wgs:long "-77.03637"^^xsd:float .
73 |
74 |
75 | :Arlington a :Area ;
76 | rdfs:label "Arlington, VA" ;
77 | geo:hasGeometry :ArlingtonGeom .
78 | :ArlingtonGeom a geo:Geometry ;
79 | geo:asWKT "ENVELOPE(-77.111, -77.052, 38.885, 38.855)"^^geo:wktLiteral .
80 |
81 | :DCMetro a :Area ;
82 | rdfs:label "DC Metro Area" ;
83 | geo:hasGeometry :DCMetroGeom .
84 | :DCMetroGeom a geo:Geometry ;
85 | geo:asWKT "ENVELOPE(-77.2, -77.0, 39, 38.7)"^^geo:wktLiteral .
86 |
--------------------------------------------------------------------------------
/using-virtual-graphs/README.md:
--------------------------------------------------------------------------------
1 | # Using Virtual Graphs
2 |
3 | Data that accompanies the [Using Virtual Graphs](https://www.stardog.com/tutorials/
4 | https://www.stardog.com/tutorials/using-virtual-graphs/) tutorial.
5 |
--------------------------------------------------------------------------------
/using-virtual-graphs/albums_by_year.sparql:
--------------------------------------------------------------------------------
1 | SELECT ?year (count(?album) AS ?count)
2 | FROM {
3 | ?album a :Album ;
4 | :date ?date ;
5 | BIND (year(?date) AS ?year)
6 | }
7 | GROUP By ?year
--------------------------------------------------------------------------------
/using-virtual-graphs/artists.sparql:
--------------------------------------------------------------------------------
1 | # this query requires reasoning and the music_schema to be loaded
2 | SELECT * {
3 | GRAPH {
4 | ?artist a :Artist ;
5 | :name ?name
6 | }
7 | }
--------------------------------------------------------------------------------
/using-virtual-graphs/beatles.sql:
--------------------------------------------------------------------------------
1 | insert into Artist values (1, 'John Lennon', 'John Winston Ono Lennon, MBE (born John Winston Lennon; 9 October 1940 – 8 December 1980) was an English singer and Songwriter who co-founded the Beatles (1960-70), the most commercially successful band in the history of popular music. With fellow member Paul McCartney, he formed a celebrated songwriting partnership.', 1);
2 | insert into Artist values (2, 'Paul McCartney', 'Sir James Paul McCartney, MBE (born 18 June 1942) is an English singer-Songwriter, multi-instrumentalist, and composer. With John Lennon, George Harrison, and Ringo Starr, he gained worldwide fame with the rock band the Beatles, one of the most popular and influential groups in the history of pop music. His songwriting partnership with Lennon is one of the most celebrated of the 20th century. After the band''s break-up, he pursued a solo career and formed the band Wings with his first wife, Linda, and Denny Laine.', 1);
3 | insert into Artist values (3, 'Ringo Starr', '"Richard Starkey, MBE (born 7 July 1940), known professionally as Ringo Starr, is an English musician, singer, Songwriter and actor who gained worldwide fame as the drummer for the Beatles. He occasionally sang lead vocals, usually for one song on an album, including "With a Little Help from My Friends", "Yellow Submarine" and their cover of "Act Naturally". He also wrote the Beatles'' songs "Don''t Pass Me By" and "Octopus''s Garden", and is credited as a co-writer of others, including "What Goes On" and "Flying".', 1);
4 | insert into Artist values (4, 'George Harrison', 'George Harrison, MBE (25 February 1943 – 29 November 2001) was an English guitarist, singer, Songwriter, and music and film producer who achieved international fame as the lead guitarist of the Beatles. Often referred to as "the quiet Beatle", Harrison embraced Hindu mythology and helped broaden the horizons of his fellow Beatles as well as their Western audience by incorporating Indian instrumentation in their music. Although the majority of the Beatles'' songs were written by John Lennon and Paul McCartney, most Beatles albums from 1965 onwards contained at least two Harrison compositions. His songs for the group included "Taxman", "Within You Without You", "While My Guitar Gently Weeps", "Here Comes the Sun", and "Something", the last of which became the Beatles'' second-most covered song"', 1);
5 | insert into Artist values (5, 'The Beatles', 'The Beatles were the greatest rock band of all time. Formed in Liverpool, England in 1960, the group was composed of members John Lennon, Paul McCartney, George Harrison and Ringo Starr. Rooted in skiffle, beat, and 1950s rock and roll, the Beatles later experimented with several musical styles, ranging from pop ballads and Indian music to psychedelia and hard rock, often incorporating classical elements and unconventional recording techniques in innovative ways. In the early 1960s, their enormous popularity first emerged as "Beatlemania", but as the group''s music grew in sophistication, led by primary Songwriters Lennon and McCartney, they came to be perceived as an embodiment of the ideals shared by the counterculture of the 1960s.', 2);
6 |
7 | insert into Membership values (1, 5);
8 | insert into Membership values (2, 5);
9 | insert into Membership values (3, 5);
10 | insert into Membership values (4, 5);
11 |
12 | insert into Album values (1, "Please Please Me", "1963-03-22", 5);
13 | insert into Album values (2, "McCartney", "1970-04-17", 2);
14 | insert into Album values (3, "Imagine", "1971-10-11", 1);
15 |
16 | insert into Track values (1, "Love Me Do", 1, 125);
17 |
18 | insert into Songwriter values (1, 1);
19 | insert into Songwriter values (1, 2);
--------------------------------------------------------------------------------
/using-virtual-graphs/beatles_members.sparql:
--------------------------------------------------------------------------------
1 | SELECT ?member ?name {
2 | GRAPH {
3 | ?band a :Band ;
4 | :name "The Beatles" ;
5 | :member ?member .
6 | ?member :name ?name .
7 | }
8 | }
--------------------------------------------------------------------------------
/using-virtual-graphs/beatles_members_birthdates.sparql:
--------------------------------------------------------------------------------
1 | SELECT ?member ?name ?birthDate {
2 | GRAPH {
3 | ?band a :Band ;
4 | :name "The Beatles" ;
5 | :member ?member .
6 | ?member :name ?name .
7 | }
8 | ?member :birthDate ?birthDate
9 | }
--------------------------------------------------------------------------------
/using-virtual-graphs/insert_birthdates.sparql:
--------------------------------------------------------------------------------
1 | INSERT DATA {
2 | :Artist1 :birthDate "1940-10-09"^^xsd:date .
3 | :Artist2 :birthDate "1942-06-18"^^xsd:date .
4 | :Artist3 :birthDate "1940-07-07"^^xsd:date .
5 | :Artist4 :birthDate "1943-02-25"^^xsd:date .
6 | }
--------------------------------------------------------------------------------
/using-virtual-graphs/music.properties:
--------------------------------------------------------------------------------
1 | # Example virtual graph configuration file for MySQL. Adjust the following parameters based on the RDBMS you are using
2 |
3 | jdbc.url=jdbc:mysql://localhost/music
4 | jdbc.username=admin
5 | jdbc.password=admin
6 | jdbc.driver=com.mysql.jdbc.Driver
7 |
--------------------------------------------------------------------------------
/using-virtual-graphs/music_schema.sql:
--------------------------------------------------------------------------------
1 | CREATE TABLE Artist (
2 | id INT,
3 | name VARCHAR(30),
4 | description VARCHAR(1024),
5 | type INT,
6 | PRIMARY KEY (id)
7 | );
8 |
9 | CREATE TABLE Album (
10 | id INT,
11 | name VARCHAR(30),
12 | release_date DATE,
13 | artist INT,
14 | PRIMARY KEY (id),
15 | FOREIGN KEY (artist) REFERENCES Artist (id)
16 | );
17 |
18 | CREATE TABLE Membership (
19 | artist INT,
20 | band INT,
21 | FOREIGN KEY (band) REFERENCES Artist (id),
22 | FOREIGN KEY (artist) REFERENCES Artist (id)
23 | );
24 |
25 | CREATE TABLE Track (
26 | id INT,
27 | name VARCHAR(30),
28 | album INT,
29 | length INT,
30 | PRIMARY KEY (id),
31 | FOREIGN KEY (album) REFERENCES Album (id)
32 | );
33 |
34 | CREATE TABLE Songwriter (
35 | song INT,
36 | writer INT,
37 | FOREIGN KEY (writer) REFERENCES Artist (id),
38 | FOREIGN KEY (song) REFERENCES Track (id)
39 | );
40 |
--------------------------------------------------------------------------------