Neil Chaudhuri
unread,Mar 15, 2012, 1:12:32 AM3/15/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to DataMapper
I have a fairly straightforward modeling task involving People,
Albums, and Photos. Here are the business rules:
*One person can have many photos.
*One album can have many photos.
*One album can have photos of many people.
*An album can have multiple photos belonging to the same person, but
not necessarily all the photos belonging to that person.
*Given an album, I would like some way to aggregate sets of photos by
the person they belong to (where each set is a subset of all the
photos that person has). So for example, I would like to say that in
Album 10, Bobby has his photos 9, 17, and 41 and Sally has her photos
47, 57, 93, 201, 203. Of course, Bobby and Sally both have a lot more
photos than that but just not in this album.
I would think the tables would look like this:
Person
id | name
Album
id | name
Photo
id | filename
PersonAlbumPhoto
person_id | album_id | photo_id
My questions are these:
*Is this a reasonable model for the business rules as I described? I
am happy to hear of something more elegant or efficient.
*How should I model my Ruby classes for Person, Album, and Photo to
generate what I need?
Thanks for the insight.