I think your first idea is better. The second way, as you state, is how you would model the data in an RDBMS. If you're going to use MongoDB for fun, you might as well explore the fact that it has a different data model, and structure your collections accordingly. While I'm sure performance is not going to be an issue for the scale of this project, keeping the data in a single document avoids joins, which can be expensive. It's commonly held that, within MongoDB environments, denormalization is faster (see here).
In the schema describe in your first idea, playlists could all be subdocuments in a kind of catch-all artist document called "various". I imagine the same would be done in a relational implementation, with the table artist
having a record for "various", to cover compilation albums and soundtracks, for example.
I have a JSFiddle here with a JSON representation of what a music collection might look like implemented as your first idea.
Of course, there is yet another way, and that is a collection albums
, with most documents having a key artist
, which could either be a reference to the _id from a document in a collection artists
, or just have the name of the artist itself. In this implementation, playlists wouldn't have this key; or, alternatively, it could be an array with all the artists with tracks in the playlist.
Is this normal behavior during the transition where they have to take themselves offline?
It is expected that your replica set instances will drop network connections when there is a change in primary.
My only concern in this situation is what happens if VM1a goes down right after LocalMongo comes up? Wouldn't that mean that the only place where data is actually being stored would be on the primary and that it would create a broken link where VM1b (which never went down) wouldn't sync to anything?
Replica set secondaries can sync off of other secondaries, which can help reduce load on your primary. If your secondaries sync source goes down, it will reevaluate and change sync source to an available member.
Best Answer
In mongoshell you can connect to several databases and use them at the same time. A plain simple copy would be this one:
Your migration script will look more complex of course, but that's the way you can do it.