I will try bake again with this model. Maybe i need modify some view manualy.
On Wed, Nov 4, 2009 at 1:05 PM, John Andersen <j.andersen
...@gmail.com> wrote:
> Actually you will have 3 tables:
> questions, answers and answers_questions
> Something like the following:
> [questions]
> id
> question
> answer_id <- the correct answer
> [answers]
> id
> answer
> [answers_questions]
> id
> answer_id
> question_id
> Observe that I changed the relation between the Question and the
> Answer for the correct Answer, so that Question belongsTo Answer - not
> the other way around. This I saw only when I tried to define the
> actual tables above.
> Whether or not you can bake this, I have no idea, I always create my
> models and tables by hand or in another tool.
> Enjoy,
> John
> On Nov 3, 8:04 pm, mufti ali <muftimas...@gmail.com> wrote:
>> Hi john, thanks for your useful solution.
>> So, in this case we have 2 tables on my database.
>> 1. questions
>> 2. answers
>> questions hasAndBelongsToMany answers
>> Answer hasAndBelongsToMany questions
>> questions hasOne answers
>> answers belongsTo questions
>> There is no troble or conflict when questions hasAndBelongsToMany
>> answers but also questions hasOne answers?
>> Anyway i will try to baking this tables;
>> Thanks
>> On Tue, Nov 3, 2009 at 8:02 PM, John Andersen <j.andersen...@gmail.com> wrote:
>> > Question hasMany optional Answer
>> > Question hasOne correct Answer
>> > What you then need is only the models to define the trivias:
>> > Question hasAndBelongsToMany Answer
>> > Answer hasAndBelongsToMany Question
>> > Question hasOne Answer
>> > Answer belongsTo Question
>> > Do observe that there are two associations between Answer and
>> > Question. CakePHP can handle that, you just have to define it!
>> > When a user is going to give the solution to each question, you would
>> > need:
>> > User hasMany Solution
>> > Solution belongsTo User
>> > Solution belongsTo Question
>> > Solution belongsTo Answer
>> > Enjoy,
>> > John
>> > On Nov 3, 7:58 am, mupet <muftimas...@gmail.com> wrote:
>> >> Hi, i will create trivia quiz application using cakePHP, i have
>> >> trouble on designing model reationship.
>> >> In this case i have question, answers and correct answer.
>> >> which is One question have 3 optional answers but have only 1 correct
>> >> answers. How to design model relationship?
>> >> Thanks and regards
>> --
>> Mufti Ali
>> 087831163105http://wordtaps.comhttp://blogfreakz.com