-
Notifications
You must be signed in to change notification settings - Fork 2
/
datomic_helpers_sample.clj
724 lines (660 loc) · 37.4 KB
/
datomic_helpers_sample.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
;;;; -*- Mode: clojure; indent-tabs-mode: nil; coding: utf-8; show-trailing-whitespace: t -*-
;;;;
;;;; =========================================================================================
;;;;
;;;; Demonstrates how to use DATOMIC-HELPERS to define schema and some data
;;;; for two well known Datomic sample databases:
;;;;
;;;; 1. The Seattle sample, distributed with Datomic. See original
;;;; schema and data in
;;;; <datomic-root>/samples/seattle/seattle-schema.edn and seattle-data0.edn
;;;; 2. The MusicBrainz sample, see original schema at
;;;; https://github.com/Datomic/mbrainz-sample/blob/master/schema.edn
;;;;
;;;; =========================================================================================
(ns datomic-helpers-sample
(:require [datomic.api :as d])
(:use clojure.test datomic-helpers))
(def db-uri "datomic:mem://dtmclj")
(d/create-database db-uri)
(def conn (d/connect db-uri))
(defn with-all [db & transactions]
(reduce #(:db-after (d/with %1 %2))
db
transactions))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Seattle sample
(let [db (with-all (d/db conn)
(to-schema-transaction
{:community/name (ext {:db/fulltext true}
:db.type/string)
:community/url :db.type/string
:community/neighborhood {:neighborhood/name :db.type/string
:neighborhood/district {:district/name :db.type/string
:district/region #{:region/n
:region/ne
:region/e
:region/se
:region/s
:region/sw
:region/w
:region/nw}}}
:community/category [ (ext {:db/fulltext true}
:db.type/string) ]
:community/orgtype #{:community.orgtype/community
:community.orgtype/commercial
:community.orgtype/nonprofit
:community.orgtype/personal}
:community/type [ #{:community.type/email-list
:community.type/twitter
:community.type/facebook-page
:community.type/blog
:community.type/website
:community.type/wiki
:community.type/myspace
:community.type/ning} ] })
(mapcat to-transaction
[{:community/name "15th Ave Community",
:community/category ["15th avenue residents"]
:community/orgtype :community.orgtype/community
:community/type :community.type/email-list
:community/url "http://groups.yahoo.com/group/15thAve_Community/"
:community/neighborhood {:neighborhood/name "Capitol Hill",
:neighborhood/district {:district/region :region/e
:district/name "East"}}}
{:community/category ["neighborhood association"]
:community/orgtype :community.orgtype/community
:community/type :community.type/email-list
:community/name "Admiral Neighborhood Association"
:community/url "http://groups.yahoo.com/group/AdmiralNeighborhood/"
:community/neighborhood {:neighborhood/name "Admiral (West Seattle)"
:neighborhood/district {:district/region :region/sw
:district/name "Southwest"}}}
{:community/category ["members of the Alki Community Council and residents of the Alki Beach neighborhood"]
:community/orgtype :community.orgtype/community
:community/type :community.type/email-list
:community/name "Alki News"
:community/url "http://groups.yahoo.com/group/alkibeachcommunity/"
:community/neighborhood {:neighborhood/name "Alki"
:neighborhood/district {:district/name "Southwest"}}}
{:community/category ["news" "council meetings"]
:community/orgtype :community.orgtype/community
:community/type :community.type/blog
:community/name "Alki News/Alki Community Council"
:community/url "http://alkinews.wordpress.com/"
:community/neighborhood {:neighborhood/name "Alki"}}
{:district/name "Southwest"}
{:community/category ["community council"]
:community/orgtype :community.orgtype/community
:community/type :community.type/website
:community/name "All About Belltown"
:community/url "http://www.belltown.org/"
:community/neighborhood {:neighborhood/name "Belltown"
:neighborhood/district {:district/region :region/w
:district/name "Downtown"}}}]))]
(d/q '[:find ?name ?category ?neighborhood-name ?district-name
:where [?c :community/name ?name]
[?c :community/category ?category]
[?c :community/neighborhood ?n]
[?n :neighborhood/name ?neighborhood-name]
[?n :neighborhood/district ?d]
[?d :district/name ?district-name]
]
db))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; MusicBrainz sample
(def mbrainz-schema
{
;; The globally unique MusicBrainz ID for the release
:release/gid (ext {:db/unique :db.unique/identity
:db/index true}
:db.type/uuid)
;; The country where the recording was released
:release/country {:db/ident :db.type/keyword
;; The name of the country
:country/name (ext {:db/unique :db.unique/value}
:db.type/string)}
;; The label on which the recording was released.
;; An issue exists: https://github.com/Datomic/mbrainz-sample/pull/2
:release/label {
;; The globally unique MusicBrainz ID for the record label
:label/gid (ext {:db/unique :db.unique/identity
:db/index true}
:db.type/uuid)
;; The name of the record label
:label/name (ext {:db/fulltext true
:db/index true}
:db.type/string)
;; The name of the record label for use in alphabetical sorting
:label/sortName (ext {:db/index true}
:db.type/string)
:label/type #{:label.type/distributor
:label.type/holding
:label.type/production
:label.type/originalProduction
:label.type/bootlegProduction
:label.type/reissueProduction
:label.type/publisher}
;; The country where the record label is located
:label/country :db.type/ref ; country entity, see above
;; The year the label started business
:label/startYear (ext {:db/index true}
:db.type/long)
;; The month the label started business
:label/startMonth :db.type/long
;; The day the label started business
:label/startDay :db.type/long
;; The year the label stopped business
:label/endYear :db.type/long
;; The month the label stopped business
:label/endMonth :db.type/long
;; The day the label stopped business
:label/endDay :db.type/long}
;; The script used in the release
:release/script {:db/ident :db.type/keyword
;; Name of written character set, e.g. Hebrew, Latin, Cyrillic
:script/name (ext {:db/unique :db.unique/value}
:db.type/string)}
;; The language used in the release
:release/language {:db/ident :db.type/keyword
;; The name of the written and spoken language
:language/name (ext {:db/unique :db.unique/value}
:db.type/string)}
;; The barcode on the release packaging
:release/barcode :db.type/string
;; The name of the release
:release/name (ext {:db/fulltext true
:db/index true}
:db.type/string)
;; The various media (CDs, vinyl records, cassette tapes, etc.) included in the release.
:release/media (ext {:db/isComponent true}
[ {
;; The set of tracks found on this medium
:medium/tracks (ext {:db/isComponent true}
[ {
;; The artists who contributed to the track
:track/artists [ {
;; The globally unique MusicBrainz ID for an artist
:artist/gid (ext {:db/unique :db.unique/identity
:db/index true}
:db.type/uuid)
;; The artist's name
:artist/name (ext {:db/fulltext true
:db/index true}
:db.type/string)
;; The artist's name for use in alphabetical sorting, e.g. Beatles, The
:artist/sortName (ext {:db/index true}
:db.type/string)
;; The mbrainz-sample says "The artist's name for use in sorting,
;; e.g. Beatles, The"
;; (https://github.com/Datomic/mbrainz-sample/blob/master/schema.edn#L66)
;; but that's most likely a typo, and it must be an enum.
;; Issue opened: https://github.com/Datomic/mbrainz-sample/issues/3
:artist/type #{:artist.type/person :artist.type/group :artist.type/other}
:artist/gender #{:artist.gender/male
:artist.gender/female
:artist.gender/other}
;; The artist's country of origin
:artist/country :db.type/ref ; country entity, see above
;; The year the artist started actively recording
:artist/startYear (ext {:db/index true}
:db.type/long)
;; The month the artist started actively recording
:artist/startMonth :db.type/long
;; The day the artist started actively recording
:artist/startDay :db.type/long
;; The year the artist stopped actively recording
:artist/endYear :db.type/long
;; The month the artist stopped actively recording
:artist/endMonth :db.type/long
;; The day the artist stopped actively recording
:artist/endDay :db.type/long} ]
;; The artists who contributed to the track
:track/artistCredit (ext {:db/fulltext true}
:db.type/string)
;; The position of the track relative to the other tracks on the medium
:track/position :db.type/long
;; The track name
:track/name (ext {:db/fulltext true
:db/index true}
:db.type/string)
;; The duration of the track in msecs
:track/duration (ext {:db/index true}
:db.type/long)
} ])
;; The format of the medium. An enum with lots of possible values
:medium/format :db.type/ref
;; The position of this medium in the release relative to the other media, i.e. disc 1
:medium/position :db.type/long
;; The name of the medium itself, distinct from the name of the release
:medium/name (ext {:db/fulltext true}
:db.type/string)
;; The total number of tracks on the medium
:medium/trackCount :db.type/long} ] )
;; The type of packaging used in the release
:release/packaging #{:release.packaging/jewelCase
:release.packaging/slimJewelCase
:release.packaging/digipak
:release.packaging/other
:release.packaging/keepCase
:release.packaging/none
:release.packaging/cardboardPaperSleeve}
;; The year of the release
:release/year (ext {:db/index true}
:db.type/long)
;; The month of the release
:release/month :db.type/long
;; The day of the release
:release/day :db.type/long
;; The string represenation of the artist(s) to be credited on the release
:release/artistCredit (ext {:db/fulltext true}
:db.type/string)
;; The set of artists contributing to the release
:release/artists [ :db.type/ref ; artist entity, see above
]
;; This release is the physical manifestation of the
;; associated abstract release, e.g. the 1984 US vinyl release of
;; "The Wall" by Columbia, as opposed to the 2000 US CD release of
;; "The Wall" by Capitol Records.
:release/abstractRelease {
;; The globally unique MusicBrainz ID for the abstract release
:abstractRelease/gid (ext {:db/unique :db.unique/identity
:db/index true}
:db.type/uuid)
;; The name of the abstract release
:abstractRelease/name (ext {:db/index true}
:db.type/string)
:abstractRelease/type #{:release.type/album
:release.type/single
:release.type/ep
:release.type/audiobook
:release.type/other}
;; The set of artists contributing to the abstract release
:abstractRelease/artists [ :db.type/ref ]
;; The string represenation of the artist(s) to be credited on the abstract release
:abstractRelease/artistCredit (ext {:db/fulltext true}
:db.type/string) }
;; The status of the release
:release/status (ext {:db/index true}
:db.type/string)
})
(def mbrainz-enums
[{:db/ident :language/eng, :language/name "English"}
{:db/ident :language/fra, :language/name "French"}
{:db/ident :script/Latn, :script/name "Latin"}
{:db/ident :country/GB, :country/name "Great Britan"}
{:db/ident :country/FR, :country/name "France"}
{:db/ident :country/MC, :country/name "Monaco"}
{:db/ident :medium.format/cd}])
(def mbrainz-data
[{:release/name "On n'est pas sérieux quand on a dix-sept ans",
:release/artistCredit "Léo Ferré",
:release/language :language/fra,
:release/status "Official",
:release/year 2000,
:release/gid #uuid "d189a947-c7cd-4005-8510-455e00d156d6",
:release/country :country/FR,
:release/script :script/Latn,
:release/barcode "794881501021",
:release/label {:label/gid #uuid "49561e52-9e40-4eb1-961b-9fde188c8b34",
:label/name "La Mémoire et la Mer",
:label/sortName "La Mémoire et la Mer",
:label/type :label.type/reissueProduction,
:label/country :country/FR},
:release/artists [{:artist/name "Léo Ferré",
:artist/startDay 24,
:artist/startYear 1916,
:artist/gender :artist.gender/male,
:artist/startMonth 8,
:artist/endDay 14,
:artist/gid #uuid "15b1cbac-060a-4136-9e07-4622c52c0f60",
:artist/country :country/MC,
:artist/type :artist.type/person,
:artist/endYear 1993,
:artist/sortName "Ferré, Léo",
:artist/endMonth 7}],
:release/media [{:medium/format :medium.format/cd,
:medium/position 1,
:medium/trackCount 16,
:medium/tracks
[{:track/artists
[{:artist/name "Léo Ferré",
:artist/startDay 24,
:artist/startYear 1916,
:artist/gender :artist.gender/male,
:artist/startMonth 8,
:artist/endDay 14,
:artist/gid #uuid "15b1cbac-060a-4136-9e07-4622c52c0f60",
:artist/country :country/MC,
:artist/type :artist.type/person,
:artist/endYear 1993,
:artist/sortName "Ferré, Léo",
:artist/endMonth 7}],
:track/artistCredit "Léo Ferré",
:track/position 10,
:track/name "Le Manque",
:track/duration 445800}
{:track/artists
[{:artist/name "Léo Ferré",
:artist/startDay 24,
:artist/startYear 1916,
:artist/gender :artist.gender/male,
:artist/startMonth 8,
:artist/endDay 14,
:artist/gid #uuid "15b1cbac-060a-4136-9e07-4622c52c0f60",
:artist/country :country/MC,
:artist/type :artist.type/person,
:artist/endYear 1993,
:artist/sortName "Ferré, Léo",
:artist/endMonth 7}],
:track/artistCredit "Léo Ferré",
:track/position 9,
:track/name "Je te donne ces vers",
:track/duration 78133}
{:track/artists
[{:artist/name "Léo Ferré",
:artist/startDay 24,
:artist/startYear 1916,
:artist/gender :artist.gender/male,
:artist/startMonth 8,
:artist/endDay 14,
:artist/gid #uuid "15b1cbac-060a-4136-9e07-4622c52c0f60",
:artist/country :country/MC,
:artist/type :artist.type/person,
:artist/endYear 1993,
:artist/sortName "Ferré, Léo",
:artist/endMonth 7}],
:track/artistCredit "Léo Ferré",
:track/position 12,
:track/name "Si tu ne mourus pas",
:track/duration 215226}
{:track/artists
[{:artist/name "Léo Ferré",
:artist/startDay 24,
:artist/startYear 1916,
:artist/gender :artist.gender/male,
:artist/startMonth 8,
:artist/endDay 14,
:artist/gid #uuid "15b1cbac-060a-4136-9e07-4622c52c0f60",
:artist/country :country/MC,
:artist/type :artist.type/person,
:artist/endYear 1993,
:artist/sortName "Ferré, Léo",
:artist/endMonth 7}],
:track/artistCredit "Léo Ferré",
:track/position 11,
:track/name "Visa pour l'Amérique",
:track/duration 318306}
{:track/artists
[{:artist/name "Léo Ferré",
:artist/startDay 24,
:artist/startYear 1916,
:artist/gender :artist.gender/male,
:artist/startMonth 8,
:artist/endDay 14,
:artist/gid #uuid "15b1cbac-060a-4136-9e07-4622c52c0f60",
:artist/country :country/MC,
:artist/type :artist.type/person,
:artist/endYear 1993,
:artist/sortName "Ferré, Léo",
:artist/endMonth 7}],
:track/artistCredit "Léo Ferré",
:track/position 14,
:track/name "L'Examen de minuit (et) Dorothée",
:track/duration 324266}
{:track/artists
[{:artist/name "Léo Ferré",
:artist/startDay 24,
:artist/startYear 1916,
:artist/gender :artist.gender/male,
:artist/startMonth 8,
:artist/endDay 14,
:artist/gid #uuid "15b1cbac-060a-4136-9e07-4622c52c0f60",
:artist/country :country/MC,
:artist/type :artist.type/person,
:artist/endYear 1993,
:artist/sortName "Ferré, Léo",
:artist/endMonth 7}],
:track/artistCredit "Léo Ferré",
:track/position 13,
:track/name "Personne",
:track/duration 389400}
{:track/artists
[{:artist/name "Léo Ferré",
:artist/startDay 24,
:artist/startYear 1916,
:artist/gender :artist.gender/male,
:artist/startMonth 8,
:artist/endDay 14,
:artist/gid #uuid "15b1cbac-060a-4136-9e07-4622c52c0f60",
:artist/country :country/MC,
:artist/type :artist.type/person,
:artist/endYear 1993,
:artist/sortName "Ferré, Léo",
:artist/endMonth 7}],
:track/artistCredit "Léo Ferré",
:track/position 16,
:track/name "Lorsque tu me liras",
:track/duration 144626}
{:track/artists
[{:artist/name "Léo Ferré",
:artist/startDay 24,
:artist/startYear 1916,
:artist/gender :artist.gender/male,
:artist/startMonth 8,
:artist/endDay 14,
:artist/gid #uuid "15b1cbac-060a-4136-9e07-4622c52c0f60",
:artist/country :country/MC,
:artist/type :artist.type/person,
:artist/endYear 1993,
:artist/sortName "Ferré, Léo",
:artist/endMonth 7}],
:track/artistCredit "Léo Ferré",
:track/position 15,
:track/name "Le Faux Poète",
:track/duration 183373}
{:track/artists
[{:artist/name "Léo Ferré",
:artist/startDay 24,
:artist/startYear 1916,
:artist/gender :artist.gender/male,
:artist/startMonth 8,
:artist/endDay 14,
:artist/gid #uuid "15b1cbac-060a-4136-9e07-4622c52c0f60",
:artist/country :country/MC,
:artist/type :artist.type/person,
:artist/endYear 1993,
:artist/sortName "Ferré, Léo",
:artist/endMonth 7}],
:track/artistCredit "Léo Ferré",
:track/position 2,
:track/name "Colloque sentimental",
:track/duration 215266}
{:track/artists
[{:artist/name "Léo Ferré",
:artist/startDay 24,
:artist/startYear 1916,
:artist/gender :artist.gender/male,
:artist/startMonth 8,
:artist/endDay 14,
:artist/gid #uuid "15b1cbac-060a-4136-9e07-4622c52c0f60",
:artist/country :country/MC,
:artist/type :artist.type/person,
:artist/endYear 1993,
:artist/sortName "Ferré, Léo",
:artist/endMonth 7}],
:track/artistCredit "Léo Ferré",
:track/position 1,
:track/name "On n'est pas sérieux quand on a dix-sept ans",
:track/duration 262266}
{:track/artists
[{:artist/name "Léo Ferré",
:artist/startDay 24,
:artist/startYear 1916,
:artist/gender :artist.gender/male,
:artist/startMonth 8,
:artist/endDay 14,
:artist/gid #uuid "15b1cbac-060a-4136-9e07-4622c52c0f60",
:artist/country :country/MC,
:artist/type :artist.type/person,
:artist/endYear 1993,
:artist/sortName "Ferré, Léo",
:artist/endMonth 7}
],
:track/artistCredit "Léo Ferré",
:track/position 4,
:track/name "Les Morts qui vivent",
:track/duration 353760}
{:track/artists
[{:artist/name "Léo Ferré",
:artist/startDay 24,
:artist/startYear 1916,
:artist/gender :artist.gender/male,
:artist/startMonth 8,
:artist/endDay 14,
:artist/gid #uuid "15b1cbac-060a-4136-9e07-4622c52c0f60",
:artist/country :country/MC,
:artist/type :artist.type/person,
:artist/endYear 1993,
:artist/sortName "Ferré, Léo",
:artist/endMonth 7}],
:track/artistCredit "Léo Ferré",
:track/position 3,
:track/name "Les Cloches (et) la Tzigane",
:track/duration 259800}
{:track/artists
[{:artist/name "Léo Ferré",
:artist/startDay 24,
:artist/startYear 1916,
:artist/gender :artist.gender/male,
:artist/startMonth 8,
:artist/endDay 14,
:artist/gid #uuid "15b1cbac-060a-4136-9e07-4622c52c0f60",
:artist/country :country/MC,
:artist/type :artist.type/person,
:artist/endYear 1993,
:artist/sortName "Ferré, Léo",
:artist/endMonth 7}],
:track/artistCredit "Léo Ferré",
:track/position 6,
:track/name "Gaby",
:track/duration 291373}
{:track/artists
[{:artist/name "Léo Ferré",
:artist/startDay 24,
:artist/startYear 1916,
:artist/gender :artist.gender/male,
:artist/startMonth 8,
:artist/endDay 14,
:artist/gid #uuid "15b1cbac-060a-4136-9e07-4622c52c0f60",
:artist/country :country/MC,
:artist/type :artist.type/person,
:artist/endYear 1993,
:artist/sortName "Ferré, Léo",
:artist/endMonth 7}],
:track/artistCredit "Léo Ferré",
:track/position 5,
:track/name "Tout ce que tu veux",
:track/duration 351666}
{:track/artists
[{:artist/name "Léo Ferré",
:artist/startDay 24,
:artist/startYear 1916,
:artist/gender :artist.gender/male,
:artist/startMonth 8,
:artist/endDay 14,
:artist/gid #uuid "15b1cbac-060a-4136-9e07-4622c52c0f60",
:artist/country :country/MC,
:artist/type :artist.type/person,
:artist/endYear 1993,
:artist/sortName "Ferré, Léo",
:artist/endMonth 7}],
:track/artistCredit "Léo Ferré",
:track/position 8,
:track/name "Le Sommeil du juste",
:track/duration 106800}
{:track/artists
[{:artist/name "Léo Ferré",
:artist/startDay 24,
:artist/startYear 1916,
:artist/gender :artist.gender/male,
:artist/startMonth 8,
:artist/endDay 14,
:artist/gid #uuid "15b1cbac-060a-4136-9e07-4622c52c0f60",
:artist/country :country/MC,
:artist/type :artist.type/person,
:artist/endYear 1993,
:artist/sortName "Ferré, Léo",
:artist/endMonth 7}],
:track/artistCredit "Léo Ferré",
:track/position 7,
:track/name "Marie",
:track/duration 359226}]}]}
{:release/name "Snow on Snow",
:release/artistCredit "Stars Of Aviation",
:release/status "Official",
:release/gid #uuid "123a923b-f710-4057-9f40-07157c6e3a11",
:release/country :country/GB,
:release/language :language/eng,
:release/script :script/Latn,
:release/year 2003,
:release/month 5
:release/day 1,
:release/label {:label/gid #uuid "b9a3521b-469f-4b19-8915-561738b86330",
:label/name "Kitchen Records",
:label/sortName "Kitchen Records",
:label/country :country/GB},
:release/artists [{:artist/gid #uuid "0530acce-9a4a-4b6b-8b49-526e74584826",
:artist/name "Stars Of Aviation",
:artist/sortName "Stars Of Aviation"}],
:release/media [{:medium/tracks
[{:track/artists
[{:artist/gid #uuid "0530acce-9a4a-4b6b-8b49-526e74584826",
:artist/name "Stars Of Aviation",
:artist/sortName "Stars Of Aviation"}],
:track/artistCredit "Stars Of Aviation",
:track/position 1,
:track/name "Snow on Snow",
:track/duration 293000}
{:track/artists
[{:artist/gid #uuid "0530acce-9a4a-4b6b-8b49-526e74584826"
,
:artist/name "Stars Of Aviation",
:artist/sortName "Stars Of Aviation"}],
:track/artistCredit "Stars Of Aviation",
:track/position 3,
:track/name
"Stars of Aviation are singing about the summer, but is it going to be sunny, Carol?",
:track/duration 207000}
{:track/artists
[{:artist/gid #uuid "0530acce-9a4a-4b6b-8b49-526e74584826",
:artist/name "Stars Of Aviation",
:artist/sortName "Stars Of Aviation"}],
:track/artistCredit "Stars Of Aviation",
:track/position 2,
:track/name "Illumined",
:track/duration 149000}
{:track/artists
[{:artist/gid #uuid "0530acce-9a4a-4b6b-8b49-526e74584826",
:artist/name "Stars Of Aviation",
:artist/sortName "Stars Of Aviation"}],
:track/artistCredit "Stars Of Aviation",
:track/position 4,
:track/name "Love Is Only in Your Mind",
:track/duration 135000}],
:medium/format :medium.format/cd,
:medium/position 1,
:medium/trackCount 4}]}])
(let [db (with-all (d/db conn)
(to-schema-transaction mbrainz-schema)
(mapcat to-transaction
mbrainz-enums)
(mapcat to-transaction
mbrainz-data))]
(d/q '[:find ?name ?track-position ?track-name
:where [?r :release/name ?name]
[?r :release/media ?m]
[?m :medium/tracks ?t]
[?t :track/name ?track-name]
[?t :track/position ?track-position]]
db))