Hi all,

I'm a programmer but new to Drupal. I'm trying to do a few things and struggling to see how they might be accomplished with CCK and Views.

Basically I'm writing a web site to automate the processes in a choral organization, and they need to model a realtionship between users and another node type I've created called "Song." They want to keep track of who knows what songs - make sense?

If I were dealing with this problem at the SQL level it would be straightforward. Another table would have records that contain the Status (i.e. "I know the song" or "I don't know the song"), and refer to a user and a song. The director could then run reports to determine what songs a person knows, or how much of the chorus knows a certain song.

So I've attempted to create a new node type called "Song Knowledge" that contains a status and refers to users and songs. I can add this relationship object via "add content" and it sort of works. I created a view to display these song knowledge records, with the user name as a parameter.

Problems:
1. Because "song knowledge" is a node, it wants to have a body, which makes no sense in this case.
2. It doesn't seem trivial to link to the relationship object in meaningful ways, like from the user record.
3. I'd like to have summary counts on the user list and the repertoire list, so it's easy to see how many songs each person knows from the user list, and how many people know each song from the repertoire list. Trivial in SQL. No clue how to accomplish this with views.

Perhaps my biggest worry is that since CCK and Views are stored in the database, when I replicate this site for another chorus I will have to worry about redoing the work, or making sure I copy an appropriately configured database. Seems like it's a maintenance problem that I could avoid if I wrote a custom module or two that created its own tables.

Any help greatly appreciated!

Tom

Comments

capmex’s picture

On the node type 'song' you can add a cck userreference field for selecting users who know the song, you can configure it to create a link on the user profile. Then with views you can create a report with exposed filters.

tmetzger’s picture

So you can use CCK to create a many-to-many relationship between nodes? People know multiple songs, and songs are known by multiple people. :) I didn't see that kind of functionality when I was looking at the CCK module but I may have missed it.

More importantly, if these entity definitions are all being created in the database, and I have a multisite environment with one database per site, doesn't that mean I have to do that CCK work in each site? That would be a huge pain... how have others solved this issue?

Thanks,
Tom

capmex’s picture

No, is one to many: one song many users. Only thing that cck offers is to create a link back to a node on the user's profile when you reference the user in the node with a userreference field.

Is not difficult to replicate the content type and the view or views once you have them defined, there are import export options for cck (content types) an views or you can create a custom module for the automatic creation of them.

For you the best option with multisite will be to create a custom module and place it on sites/all/modules to share it with all sites, then you can simply enable the module where you need the content type song and the view or views related to it.

916Designs’s picture

I think this relationship is M:M. One song is known by many users, yes, but one user also knows many songs. On the song page, links to users who know it is great, but the user's profile page needs a link to each song they know.... many-to-many.

I am also struggling with implementing many to many in Drupal. I also need my M:M relationships to have attributes.

Could someone please point me in the right direction? The only leads I have are the Node2Node module, or writing something from scratch. I'm thinking that the from scratch approach would involve creating a "relationship" content type with nodereferences to both the user and the song. The relationship content type would also have my desired attributes (e.g. Skill at singing). Then, somehow I need a slick UI to essentially hide the relationship content type and only manipulate it through user and song editing.

Someone please help...