I am setting up a website that will have users. Users can search for songs and (if signed in) save them to a playlist or their library of songs.
I want it to be like iTunes in that all the songs on the the playlists are part of the library so when the user choses to view their library of songs, the songs on the playlists are shown as well as the songs just added to the library. I'd like a song to be able to be stored in multiple playlists.
Right now I am using Mongodb, doing something like such:
var UserSchema = new Schema();
var Library = new Schema({
songs: [SongsSchema],
user: Schema.ObjectId
});
var Playlist = new Schema({
title: String,
description: String,
user: Schema.ObjectId
});
var SongsSchema = new Schema({
position: Number,
name: String,
artist: String,
artistGid: String,
album: String,
albumGid: String
time: Number,
url: String,
gid: String,
location: String (either youtube, vimeo, soundcloud for now),
playlist: [Schema.ObjectId] (array of object ids that point to playlists?)
});
Does this seem the best? I am used to relational so it seems like there is lots of duplication but I was having a hard time normalizing it in a way that would work.