Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Trivia quiz model relationship
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
mupet  
View profile  
 More options Nov 3, 4:58 pm
From: mupet <muftimas...@gmail.com>
Date: Mon, 2 Nov 2009 21:58:49 -0800 (PST)
Local: Tues, Nov 3 2009 4:58 pm
Subject: Trivia quiz model relationship
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


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Andersen  
View profile  
 More options Nov 4, 12:02 am
From: John Andersen <j.andersen...@gmail.com>
Date: Tue, 3 Nov 2009 05:02:29 -0800 (PST)
Local: Wed, Nov 4 2009 12:02 am
Subject: Re: Trivia quiz model relationship
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:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mufti ali  
View profile  
 More options Nov 4, 5:04 am
From: mufti ali <muftimas...@gmail.com>
Date: Wed, 4 Nov 2009 01:04:54 +0700
Local: Wed, Nov 4 2009 5:04 am
Subject: Re: Trivia quiz model relationship
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

--
Mufti Ali
087831163105
http://wordtaps.com
http://blogfreakz.com

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Andersen  
View profile  
 More options Nov 4, 5:05 pm
From: John Andersen <j.andersen...@gmail.com>
Date: Tue, 3 Nov 2009 22:05:35 -0800 (PST)
Local: Wed, Nov 4 2009 5:05 pm
Subject: Re: Trivia quiz model relationship
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:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mufti ali  
View profile  
 More options Nov 4, 10:10 pm
From: mufti ali <muftimas...@gmail.com>
Date: Wed, 4 Nov 2009 18:10:16 +0700
Local: Wed, Nov 4 2009 10:10 pm
Subject: Re: Trivia quiz model relationship
I think this model relationship more better, so we have
[answers_questions] for HABTM relationship, Question belongsTo Answer.
I will try bake again with this model. Maybe i need modify some view manualy.

Again, thanks john, very helpfull

--
Mufti Ali
087831163105
http://wordtaps.com
http://blogfreakz.com

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google