Monday, July 30, 2012

Re: Entity Relationship: What's the best solution for CakePHP?

1. 
One Source has Many Comments? 

2.
One Comment has Many Sources?

3.
The same Source can have Many Comments?



1.
Comments table should have source_id inside.
($belongsTo = array('source'); )

2.
Sources table should have comment_id inside.
($belongsTo = array('comment'); )

3.
Create a comments_sources table with
Id
Comment_id
Source_id


I would not create a comment table for every source, you don't need it.

http://book.cakephp.org/2.0/en/models/associations-linking-models-together.html



=============================
Walter Raponi
Din S.r.l.
Via Donato Menichella 304
00156 Roma - Italy

Tel  0641227662
Fax 0641227664

Il giorno 30/lug/2012, alle ore 22:54, Leonhart <andrea.tantimonaco@gmail.com> ha scritto:

Hi guys ;)
I hope I'm not abusing this group for a technical question.

I'm kinda new in CakePHP and it's the first time I'm using it for a true-app development. I want to learn how to create the best suitable database for CakePHP and I'm stuck in the following scenario:
I've a "Comments" table and many sources for the comments. Should I create a "Sources" table for keeping just one comment table or create a comment table for each source? What's the best solution suitable for the CakePHP conventions?

Thanks in advance!!

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: