I\'m looking to build an appropriate data structure for NoSQL storage of a photo gallery. In my web application, a photo can be part of 1 or more albums. I have experience with
Redis can handle this. For the RMDBS table you mentioned above:
SET photos:photo_id:title "some photos title words"
SET photos:photo_id:date_uploaded "some uploaded time (2011-02-09 HH:MM:SS for example)"
SET photos:photo_id:filename "some filename words"
SET albums:album_id:title "some album title words"
SADD album_photo_map:photo_id album_id
Use a List(Redis suports list) to store last uploaded photos and update the list when a new photo is uploaded:
ret = r.lpush("upload:last_upload_times", photo_id) // update list
ret = r.ltrim("upload:last_upload_times", 0, N-1) // control list length
then, if we want to get the last uploaded N photos with album data:
last_uploaded_photo_list = r.lrange("upload:last_upload_times", 0, N-1) last_uploaded_photo_with_album_list = [(photo_id, album_id) for photo_id in last_uploaded_photo_list for album_id in r.smembers(photo_id)]