Monday, February 25, 2013

CakePHP - how should I do these relationships and name my tables?

It's a song and lyrics database. I'm trying to bake an app from my database, which looks like this: (every table does have a primary key 'id', I just left them out..)

    songs
        song_name

    artists
        artist_name

    songs_singers
        artist_id (FOREIGN KEY artists.id)
        song_id (FOREIGN KEY songs.id)

    songs_writers
        artist_id (FOREIGN KEY artists.id)
        song_id (FOREIGN KEY songs.id)

    song_views
        song_id (FOREIGN KEY songs.id)

    videos
        song_id (FOREIGN KEY songs.id)

    video_views
        video_id (FOREIGN KEY videos.id)


Writers and singers both overlap, i.e. some writers sing and some singers write.

When I bake the songs table, I get this error:
   Error: Table singers for model Singer was not found in datasource default.

I think the problem is that CakePHP wants me to create a new model for singers, so I'll have to end up duplicating the names of writers and singers in a new table singers. I just want the names stored in artists and have both song_singers and song_writers link to that table with foreign key IDs.

songs have many:
* views
* videos

videos have many:
* views

both writers and singers have many:
* songs

What should I do?

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: