mysql - Normalisation of product/protocol review system -


i'm working on review system, reviews products shown based on outcome of questionnaire.

example:

  1. what food (italian, french or fusion)
  2. which vegetables (spinach, tomato or broccoli)
  3. how money spend on dinner ($0-$10, $11-$20 or $21-$30)

if selects italian, tomato, $0-$10, user see (for example) 20 types of pizza's, reviews other users shown. want show products have been reviewed exact same outcome of questionnaire (we call protocol).

table: questions ----------------------------------- | id | question                   | ----------------------------------- | 1  | food      | ----------------------------------- | 2  | vegetables you... | -----------------------------------  table: possible_answers ----------------------------------- | id | question_id | answer       | ----------------------------------- | 1  | 1           | italian      | ----------------------------------- | 2  | 1           | french       | -----------------------------------  table: products --------------------- | id | product      | --------------------- | 1  | pizza salami |  --------------------- | 2  | pizza cheese |  --------------------- 

from database perspective (we're using mysql), i'm wondering how store protocol attached each review

[option 1] table: reviews --------------------------------------------------------------------------- | id | product_id   | answer_q1_id | answer_q2_id | answer_q3_id | rating | --------------------------------------------------------------------------- | 1  | 2            | 3            | 57           | 166          | 4      | --------------------------------------------------------------------------- | 2  | 25           | 3            | 57           | 166          | 5      | --------------------------------------------------------------------------- [/option 1]   [option 2] table: reviews ------------------------------- | id | product_id   | rating | ------------------------------- | 1  | 2            | 4       | ------------------------------- | 2  | 25           | 5       | -------------------------------  table: protocol ----------------------------------------------- | id | review_id    | question_id | answer_id | ----------------------------------------------- | 1  | 1            | 1           | 3         | ----------------------------------------------- | 2  | 1            | 2           | 57        | ----------------------------------------------- | 2  | 1            | 3           | 166       | ----------------------------------------------- [/option 2] 

normally, i'd go option 2 'feels' better. i'm not sure how 1 query protocol table product reviews specific path in questionnaire (protocol). example when user answers 'italian, spinach, 0-10', how find out product reviews go combination of answers using option 2 (with option 1 obvious how this)?

i hope i've explained , i'm looking forward reading thoughts community.

greatly appreciated,

lionel.


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -