All Projects β†’ Datomic β†’ Mbrainz Sample

Datomic / Mbrainz Sample

Example queries and rules for working with the Datomic mbrainz example database

Programming Languages

clojure
4091 projects

Datomic MusicBrainz sample database

Datomic is a database of flexible, time-based facts, supporting queries and joins with elastic scalability, and ACID transactions.

MusicBrainz is an open music encyclopedia that collects music metadata and makes it available to the public. This sample project uses the MusicBrainz dataset, but is in no way affiliated with or sponsored by MusicBrainz.

The MusicBrainz dataset makes a great example database for learning, evaluating, or testing Datomic. To create this sample database, we have exported the MusicBrainz distribution database as EDN data files, imported that data into Datomic according to the Schema described below, and backed up that database.

Included in this project are:

  • Instructions for downloading and restoring the Datomic backup to your local transactor
  • Datomic Datalog rules to be composed together to create interesting queries
  • Some sample queries as a starting point

Getting Started

Getting Datomic

First download a Datomic distribution and unzip it somewhere convenient:

wget http://downloads.datomic.com/$VERSION/datomic-free-$VERSION.zip
unzip datomic-free-$VERSION.zip

For this walk-through, we'll use Datomic Free and local storage, but you could use Datomic Pro with any of the available storage options by uncommenting the Pro dependency in project.clj.

Then, start the transactor:

cd datomic-free-$VERSION
bin/transactor config/samples/free-transactor-template.properties

Getting the Data

Next download the subset of the mbrainz database covering the period 1968-1973 (which the Datomic team has scientifically determined as being the most important period in the history of recorded music):

wget https://s3.amazonaws.com/mbrainz/datomic-mbrainz-1968-1973-backup-2017-07-20.tar -O mbrainz.tar
tar -xvf mbrainz.tar

Finally, restore the backup:

# prints progress -- ~1,000 segments in restore
bin/datomic restore-db file:///path/to/backup/mbrainz-1968-1973 datomicπŸ†“//localhost:4334/mbrainz-1968-1973

Windows users should specify the backup path using the file:///C:/path/to/backup format and specify a basis-t to restore.

Getting the Code

Clone this git repo somewhere convenient:

git clone [email protected]:Datomic/mbrainz-sample.git
cd mbrainz-sample

Running the examples

From Java

Fire up your favorite IDE, and configure it to use both the included pom.xml and the following Java options when running:

-Xmx2g -server

Then visit the queries page.

From Clojure

Start up a Clojure REPL:

# from the root of this mbrainz-sample repo
lein repl

Then connect to the database and run the queries.

Schema

Here is a diagram of the relationships:

Mbrainz Relationships

For information about the schema in general, or about individual entities and their attributes, please see the schema page in the wiki, or the EDN schema itself.

Example Queries and Rules

Please see the queries page in the wiki.

Thanks

We would like to thank the MusicBrainz project for defining and compiling a great dataset, and for making it freely available.

Contributing

This tutorial is developed internally by Cognitect. Issues can be filed using Github Issues. We do not accept pull request or patches.

License

Copyright Β© Metadata Partners, LLC. All rights reserved.

Distributed under the Eclipse Public License, the same as Clojure.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].