Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2006
    Posts
    36

    Question Mapping questions to relational tables

    I am storing answers to an application form.
    An example I am unsure of is the following:
    What are the criteria for euthanasia? (Multiple-selection)
    Options: a: sickness b: behavioural problems c: lack of space d: other, please describe:________________;

    This is a one-to-many scenario and I have created 3 tables to map the question. My tables are as follows:

    EUTHANASIA (euth_id, soc_id[FK], .........) ;parent table
    EUTH_CRITERIA (id, euth_id[FK], criteria);
    EUTH_CRITERIA_OTHER (id, euth_id[FK], other_description);

    criteria stores the selections of a,b,c,d;
    EUTH_CRITERIA_OTHER stores the description if 'other' is chosen.

    Is this a good way of storing data. I know it prevents null values being entered, I'm just not sure its the best way to do it. Are there any flaws that I'm not seeing? Your comments would be appreciated.
    Last edited by grooverinthesouth; 05-05-06 at 09:52.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    it is not clear from your post whether those tables are to store the questions or the answers

    if they are for the questions, then of course the EUTH_CRITERIA_OTHER table is not required, since the "other" reason isn't given in the question

    if they are for the answers, where is the column to indicate whose answers they are?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Mar 2006
    Posts
    36
    The EUTHANASIA table has a foreign key called 'soc_id' which refers to the society for which the euthanasia question refers to.
    The tables store the answers. Its basically a data capture db which will produce reports and summaries on societies.

    NOTE: I have included the foreign key in my original post now.
    Last edited by grooverinthesouth; 05-05-06 at 09:51.

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    yeah, that works

    me, personally, i wouldn't have a separate table for other_description, i would make it a nullable column in the criteria table

    now hang on to your hat because the relational nazis will be along any second to castigate my intelligence and cast aspersions on my lineage

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Mar 2006
    Posts
    36
    You vain bastŁ$d! ;-) Cheers for the comments. Much appreciated!
    Clears my chest.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •