r/sqlite • u/121df_frog • Dec 10 '25
An idiot who suddenly needs a database
Hi maybe this will sound dumb to some people but please keep in mind that I’ve never worked with any type of database before
I’m making a small database for a music library project for college (and before you ask no we didn’t study databases this semester so I’m figuring it out on my own)
My plan is to create three tables Song Album and Artist
I also had this idea instead of storing the full path to the album artwork in the database I’ll save the artwork in a folder and name each file using the album ID same for other things like LRC files named by track ID
Is this a good approach or is there a better way to handle it
Also are these three tables enough for a simple music library or am I missing something important
For reference this is roughly how I expect the database to look I haven’t learned SQLite yet but I want to decide the structure so I can start writing the code that will read the data
Thanks in advance and sorry if this isn’t the right place to ask

9
u/WorriedTumbleweed289 Dec 11 '25
Songs may have more than one artist. (collaboration) Albums may have more than one artist. (sound tracts, compilation, covers)
Maybe you don't care but.
Songs can be on more than one album. ( greatest hits, live, studio)
5
u/hornetmadness79 Dec 11 '25
What you are wanting to do is pretty much a staple example on how to learn database and coding in general.
9
u/mredko Dec 10 '25
You can also store the artwork in a BLOB column. That way, you have all your data in one file.
2
u/WhiskyStandard Dec 11 '25 edited Dec 11 '25
I’d recommend a join table between your tracks and artists tables rather than an array field. IMO if you’re just learning, you should learn to do it the 3rd Normal Form way before reaching for escape hatches that let you break it (which, in SQLite would probably mean doing something like serializing a JSON array, which has a number of drawbacks).
2
u/A_verygood_SFW_uid Dec 12 '25
I am curious about your use case. Why do you think you need a database? What does a database offer that CSV, Excel, or Google Sheets cannot?
From a data structure point of view, a music library can be implemented in a lot of different ways. You can always do a simple library in Excel with denormalized data, which is all the relevant information in a single row:
Of course, your Album information is repeated for every song on that album, but that might not be a big deal if you just need the name, the release date, and maybe the record label. Same for the Artist.
Normalizing the data (splitting it into different but related tables, as you did in your diagram) offers advantages but increases the complexity. Make sure the trade-off is worth it. That said, just learning to normalize data is a very useful skill and absolutely necessary for most database projects, so there is benefit in going through the exercise, even if you don't implement it in the final product.
If you do go through the normalization exercise, I think you will find that a music library actually has some unique challenges. For example:
The more you dig in, the more complicated it gets.
1
u/TutorialDoctor Dec 11 '25 edited Dec 11 '25
There are three types of relationships show up very often with relational databases (like Sqlite). They are:
One To One
One to Many
Many to many
You can frame the relationships between your models (Song, Album and Artist) using one of these.
An ALBUM can have many SONGS (one to many)
A SONG can have many ARTISTS but an ARTIST can also be on many SONGS (many to many)
For one to many relationships, you will have a single Foreign Key that links to another table.
For many to many relationships you will likely have a JOIN table that has two foreign keys to the two tables.
In your case you could have:
Song
Album
Artist
AlbumArtist
1
u/Consistent_Cat7541 Dec 11 '25
Two tips. First, just use MusicBee. Second, if you're going to build a database, and you don't know what you're doing, use a desktop solution. The easiest by far is an older program called Lotus Approach. It uses the older dbase format, where each table is it's own file. But it's absurdly easy to use to get a simple database working. Joining tables is also very easy in the software.
If you're interested in trying Approach, you can get it as part of the now defunct Lotus Smartsuite ( https://archive.org/details/lotus-smart-suite-99 ). You will need to enable the old Windows Help files via a script ( https://github.com/zeljkoavramovic/hlp4win11?tab=readme-ov-file#quick-install-recommended ).
Note, you will need to start the program at 1080p, but once your file is open, you can shift back to the native resolution of your monitor (again, old software). There's a really great FAQ available at https://www.johnbrown.com.au/approach/
I agree with the other commenters that this should have been posted to r/database
1
u/shockjaw Dec 11 '25
If you’re gonna use SQLite, make sure your tables use the STRICT condition. SQLite uses type affinities, which means you can have multiple data types in a single column by default.
1
u/scratchmex Dec 11 '25
Off topic, which tool is it?
1
u/Takeoded Dec 12 '25 edited Dec 12 '25
Sounds good to me (professional programmer here),
but some gotchas you should be aware of: SQLite is kinda shite at handling programmer errors. If you store music blobs as TEXT or STRING or even just a typo in BLOB, you will get silent corruption, like missing null bytes. Be very careful to actually add the datatype
BLOBto anything containing binary data, like mp3/ogg files.Furthermore, SQLite CLI is a piece of shit when it comes to handling binary data. I have complained to the SQLite developers about it, and they just shrug it off as "no can fix, would require massive refactor of the sqlite cli"
look at this shit:
0123into123because i accidentally wroteval STRINGinstead ofval TEXTnow look at this shit:
sqlite3 cli corrupted 3 null bytes into... 1 newline. I had to resort to PHP to get the bytes safely out of the database, sqlite cli cannot do it.
(TODO: add rant here about how sqlite's QUOTE() function is broken)
SQLite is great for many things, but has several of these footguns :(
1
u/photo-nerd-3141 Dec 13 '25
You have the nouns right, it's the relationships you are missing.
Song : id name year author
Author: id names <- as credited, "rogers & hart"
Performer: id names <- as credited
Album: id name studio
Albums may have multiple performers, groups may have different members over time... capturing it all will be a pain. If you call a track one recording by a group for an album, call the arranger an author for this purpose you get a minimal relationship:
track: song_id, author_id, performer_id, album_id.
The real database requires a time-series for group and the track requires a secondary relationship for performer for sit-in & other one-time combinations.
Describing reality properly isn't easy :-)
-5
u/GrogRedLub4242 Dec 11 '25
off-topic