Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4084092
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:23:45+00:00 2026-05-20T18:23:45+00:00

I have a quiz application. Which follows a normal pattern of database development Quiz

  • 0

I have a quiz application. Which follows a normal pattern of database development

Quiz –> QuizQuestions –> QuizQuestionChoices

QuizAttempt –> QuizAttemptAnswer

In quiz_attempt_answers I store the answer as a string instead of a reference to QuizQuestionChoices for the following reason.

  1. If the question gets deleted from the quiz (maybe it the quiz gets revised), we don’t want to lose what they put in.
  2. If the choices get changed or rearranged, we want to have the answer they chose

Are these valid reasons for NOT using a foreign key for the answer?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T18:23:45+00:00Added an answer on May 20, 2026 at 6:23 pm

    I would continue with your approach but store the association as well.

    So…

    class QuizQuestionChoice < ActiveRecord::Base
      has_many :quiz_attempt_answers, :dependent => :nullify
    end
    
    class QuizAttemptAnswer < ActiveRecord::Base
      belongs_to :quiz_question_choice
    end
    

    That way if a QuizQuestionChoice is deleted the foreign_key is set to null AND you still have their actual answer.

    There are cases where you may even store the original question with the answer. In case somebody changes the wording which unintentionally changes the meaning of it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing an intranet web application which is a Quiz Engine. I have
We have a quiz application ( which is capable of rendering a question bank
I have a .net MVC application which opens up the result of a Quiz
I'm currently building a quiz application for facebook, which would have a photo uploaded
I have a simple quiz application and I want display a nice timer /
I have forms which work fine. I have a quiz which works fine. When
I am developing a Quiz game application which is being developed completely but at
I am trying to write a quiz application.i have the follwing model. class Question(db.Model):
I'm trying to grade a quiz application I would like to make. I have
I have an AsyncTask which is executed just before my application quits. It gets

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.