The theoretical true minimum is only two things:
- The composer
- The catalogue or opus number
- The movement number
However, there are some problems.
Generally this should be fine, however you have to be prepared to deal with all the usual problems with identifying humans by name.
Some composers are from musician families so you have to store at least all the first names as well.
For example, the large Bach family, the father and son Leopold and Wolfgang Mozart - I don’t believe Franz Xaver Mozart really comes up ever –, there are at least two Haydns and (Ludwig) van Beethoven had a composing brother Anton. In the case of Beethoven you have the additional problem of the prefix “van” (Dutch/Flemish “of”) which is regularly Germanised (“von”) and often even just omitted.
Of course these are just the tip of the iceberg. In each of these cases one family member is tremendously more famous than the others, but that’s not always the case (e.g. Dussek, Franz Xaver and Jan Ladislav, who are equally obscure).
I’m sure as a programmer you know the problems surrounding identifying humans by name much better than I do. The only thing that might surprise you is that classical music deals with very old names, so they are even less regulated than modern ones. For instance, some names are fully translatable (Orlando di Lasso).
The catalogue or opus number
This is a much hairier category. I will first discuss opus and catalogue numbers separately, but theoretically storing just one (either one) is enough since they are both meant to be identifying numbers. However, the problems below complicate things and many pieces have only one of the two kinds of numbers.
Many composers have a very well-documented list of all pieces (the more famous the composer, the more likely they’ll have one) in which each piece has an identifying number. However even in the catalogue for Mozart (called KV – Köchels Verzeichnis) there are some works which tantalisingly have 2 catalogue numbers and some have a letter suffix (e.g. “KV 448/375a”). I’m sorry, but I never took the time to find out where the double numbers come from. In case of Mozart the letter suffix is often used to indicate obscure works that are closely related to another.
Opus numbers were assigned by the publishing company at the time the work was first published (generally speaking). They sometimes have a secondary number in case multiple pieces are published together, e.g. Chopin’s op. 25 nr. 3 means the third piece in the bundle of pieces that were published together as op. 25 (as it happens, that’s his second and last set of 12 studies/etudes). (“Nr.” and “no.” are used interchangeably.) Although these bundles are common, many pieces (especially longer works) are just published by themselves, e.g. the Paganini concerto you mentioned, which is op. 6 all by itself.
The first complication is that not all works have an opus number, for various reasons. Firstly, there is no composer who managed to have every single piece they wrote published. For example, there are many pieces that were written by famous composers when they were very young which we study now because they later became famous, but obviously at the time there was no reason to publish a child’s piece. Another reason is the fact that the practice of giving opus numbers only really starts in the second half of the eighteenth century.
A second complication is that occasionally these opus numbers are unreliable. As you may imagine this applies especially to early opus numbers. If a composer sold pieces to more than one publisher, these publishers might not synchronise their lists. I believe this happened to Haydn, but I don’t know which piece off the top of my head. I don’t know of examples in the nineteenth century and later, but I wouldn’t want to bet that there aren’t any (although by then it was standard practice and the later in time the better communication technologies become of course.)
Occasionally you will run into “Opus Posthumus”. You can disregard it, it just means the piece was published after the composer’s death, but it doesn’t impact the numbering.
Because works by a composer are sometimes counted per form as well (“concerto no. 3” for example), occasionally this gets mixed up with the opus numbering; for example, Beethoven’s opus 7 is a single piece: his fourth piano sonata. If you want to include both numberings you should write “Beethoven’s Sonata no. 4, op. 7” to distinguish from “Beethoven’s Sonata op. 7 no. 4” (doesn’t exist) which would mean the fourth piece (apparently a sonata) from the bundle numbered opus 7. The difference is only in the order and occasionally people get this wrong. It’s not inherent in the numbering scheme but you’ll likely run into this confusion. If I really have to mention both numbers I personally prefer to make the sonata number an adjective to avoid using the confusion stemming from seeing the abbreviation “no.” twice : “Beethoven’s fourth [/4th] sonata, op. 7”.
Depending on your use case you might or might not need it. If each movement is going to be in a separate file you would of course need to differentiate between them (and what better way to do it than the inherent order of the movements), but – to be slightly pedantic – they do not matter to the identification of the work (since the various movements are by definition part of the same work).
However, in certain cases it’s unclear whether something is a single multi-movement piece or a collection of single-movement pieces. This applies especially in the nineteenth century (and later) because then it becomes more and more common to give free titles to works instead of just indicating the form. For example, if you have a number of seemingly separate pieces that are together called “sonata” it’s clear that it’s a single multi-movement work (because a sonata typically has multiple movements) but if you get a bundle called “Dichterliebe” or “Années de Pèlerinage” the title doesn’t give any information about that (and the distinction perhaps becomes less important). In some cases this means it’s hard to distinguish whether the contents of an opus have to be classified as “opus X no. 1 through N” or “opus X, movements 1 through “).
I strongly recommend against using the title for work identification. Many classical pieces don’t have titles, but instead are named after their form, possibly with a number (e.g. “Concerto no. 2”). This means that they can be translated and reformulated (e.g. “Deuxième concert”, “second concerto” or “piano concerto no. 2” could all reference the same work and could all be considered its title). Additionally, some works were later given nicknames (“the moonlight sonata” or “revolutionary etude” for example) which were not intended by the composer and therefore aren’t titles. It’s not possible to tell whether a title is original or was given later without looking it up (unless you happen to know it of course). Not so easy for computers.
Okay, so what if there is no catalogue or opus number? Then you have a problem.
It should be a rather rare situation, but problematic nonetheless.
There is a big library of public domain scores at imslp.org. I believe they assign all pieces that they have stored an “I-catalogue” number, which you could conceivably use, possibly scraping some of the metadata from the IMSLP page. But I find it hard to say anything about it without knowing your use case better.
Probably for pieces without identifying numbers there will be some manual work involved. Possibly this is not the only case in which that will be necessary. In the end, music, as all art, is hard to describe in a format suitable for a computer. Maybe one could compare it to natural language processing.