# Database for a DJ library

**URL:** <https://forum.juce.com/t/database-for-a-dj-library/26956>\
**Category:** General JUCE discussion\
**Created:** [March 25, 2018, 11:27am UTC](https://forum.juce.com/t/database-for-a-dj-library/26956 "2018-03-25T11:27:51Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![samspreadborough](https://avatars.discourse-cdn.com/v4/letter/s/74df32/32.png) [@samspreadborough](https://forum.juce.com/u/samspreadborough)\
**Post date:** [March 25, 2018, 11:27am UTC](https://forum.juce.com/t/database-for-a-dj-library/26956/1 "2018-03-25T11:27:51Z")

</div>

Hello.

I’m needing to build a database of audio files for use with a DJ application.  
I’d like to be able to handle nested playlists of tracks, and to be able to sort and search by metadata values.

Does JUCE offer anything like that, or should I be looking at something like SQL?

Many thanks

---

<div class="post-metadata">

**Author:** ![xenakios](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/xenakios/32/4047_2.png) [@xenakios](https://forum.juce.com/u/xenakios)\
**Post date:** [March 25, 2018, 11:32am UTC](https://forum.juce.com/t/database-for-a-dj-library/26956/2 "2018-03-25T11:32:41Z")

</div>

Obviously you could use JUCE’s data structures or things from the C++ standard library. But it might be better in the long run to use something like Sqlite. (A full blown server process based database probably isn’t going to be necessary.)

[https://www.sqlite.org/index.html](https://www.sqlite.org/index.html)

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [March 25, 2018, 11:36am UTC](https://forum.juce.com/t/database-for-a-dj-library/26956/3 "2018-03-25T11:36:18Z")

</div>

To have persistency I would recommend SQL. I was thinking of writing a JUCE module that wraps SQLite, but the project died for other reasons.

Also it would be cool to implement an abstraction layer, so that you can use any kind of database adapter to the usual suspects. I would just start writing the sqlite adapter and if someone needs a bigger database, they can extend that later…

and +1 to @Xenakios, sqlite is definitively the one to start with

---

<div class="post-metadata">

**Author:** ![samspreadborough](https://avatars.discourse-cdn.com/v4/letter/s/74df32/32.png) [@samspreadborough](https://forum.juce.com/u/samspreadborough)\
**Post date:** [March 25, 2018, 11:46am UTC](https://forum.juce.com/t/database-for-a-dj-library/26956/4 "2018-03-25T11:46:07Z")

</div>

Fantastic!  
I imagine I won’t be the first or last person to want to do something like this.  
I’ll give SQLite a go, and if it goes well I’ll post it on github and link it here.

---

<div class="post-metadata">

**Author:** ![jimc](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jimc/32/16067_2.png) [@jimc](https://forum.juce.com/u/jimc)\
**Post date:** [March 25, 2018, 11:59am UTC](https://forum.juce.com/t/database-for-a-dj-library/26956/5 "2018-03-25T11:59:33Z")

</div>

Sqlite is excellent.

Pick your threading model carefully though and follow the manual…

---

<div class="post-metadata">

**Author:** ![samspreadborough](https://avatars.discourse-cdn.com/v4/letter/s/74df32/32.png) [@samspreadborough](https://forum.juce.com/u/samspreadborough)\
**Post date:** [April 6, 2018, 5:16pm UTC](https://forum.juce.com/t/database-for-a-dj-library/26956/6 "2018-04-06T17:16:18Z")

</div>

I ended up using two std::maps for my tracks and playlists, accessed by an index key.  
Turns out Cereal works nicely with std::maps, so that made it super simple to serialise.

Has anyone had experience using Cereal?  
I’ve written some serialisation functions for some JUCE classes, and if they’re useful I’m happy to share them

---

<div class="post-metadata">

**Author:** ![refusesoftware](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/refusesoftware/32/20561_2.png) [@refusesoftware](https://forum.juce.com/u/refusesoftware)\
**Post date:** [May 27, 2023, 4:21pm UTC](https://forum.juce.com/t/database-for-a-dj-library/26956/7 "2023-05-27T16:21:35Z")

</div>

> [@daniel](#):
>
> I was thinking of writing a JUCE module that wraps SQLite, but the project died for other reasons.

Did you ever come back to this? I was considering ways to integrate SQLite in a project.

This CPP wrapper for SQLite would probably handle most of the heavy lifting:

> **[GitHub - SRombauts/SQLiteCpp: SQLiteC++ (SQLiteCpp) is a smart and easy to...](https://github.com/SRombauts/SQLiteCpp)**
>
> SQLiteC++ (SQLiteCpp) is a smart and easy to use C++ SQLite3 wrapper. - GitHub - SRombauts/SQLiteCpp: SQLiteC++ (SQLiteCpp) is a smart and easy to use C++ SQLite3 wrapper.
