Model association, I've made it correctly???

2010-10-17 Thread Mariano C.
I'm studing model associations, I would know if i've understand it
correctly:

I have five tables: users, books, books_users, authors and types.
users, authors and types just have PK field called id.
books have PK called id and FK called author_id (ref. Authors)
books_users have PK called id and 3 FKs user_id, book_id, type_id
(respectively Ref. users, books, types).

I have create 5 model (Book, Author, User, BooksUser and Type) and
arranged the associations as:
Book belongsTo Author
Book hasMany BooksUser

Author hasMany Book

User hasMany BooksUser

BooksUser belongsTo Book, User, Type

Type belongsTo BooksUser


Is this correct???
Regards

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Model association, I've made it correctly???

2010-10-17 Thread euromark
you probably meant
Type hasMany BooksUser...


On 17 Okt., 22:17, Mariano C. mariano.calan...@gmail.com wrote:
 I'm studing model associations, I would know if i've understand it
 correctly:

 I have five tables: users, books, books_users, authors and types.
 users, authors and types just have PK field called id.
 books have PK called id and FK called author_id (ref. Authors)
 books_users have PK called id and 3 FKs user_id, book_id, type_id
 (respectively Ref. users, books, types).

 I have create 5 model (Book, Author, User, BooksUser and Type) and
 arranged the associations as:
 Book belongsTo Author
 Book hasMany BooksUser

 Author hasMany Book

 User hasMany BooksUser

 BooksUser belongsTo Book, User, Type

 Type belongsTo BooksUser

 Is this correct???
 Regards

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en