January 27th, 2014, 06:42 AM
DB questions (db design & replication)
Hi i have few questions:
1. I am creating a survey, where users can either choose an option or do a free text response.
Should I create something like:
response_choice ( question_id, choice_id, user_id )
response_answer (question_id, response, user_id)
or have one table:
response ( q_id, c_id, response, u_id )
The problem with this is that i cant do indexes at mysql level. the problem with the first one is, i would somehow need to check if question is a free text one or choice id, then lookup appropriate table.
if i was to have vouchers, how should I store them?
Question_id, vouchers, user_id, email
and then update the vouchers table with user_id/email once they get taken?
Q 3: replication. I would like to do a backup. One way is to just do a trigger maybe on each table? another way would be to store all queries in a table which get run periodically.