+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 18

Thread: Database table design

  1. #1
    Barn Newbie Ziggy is an unknown quantity at this point Ziggy's Avatar
    Join Date
    Feb 2009
    Posts
    22
    Rep Power
    4

    Database table design

    Hi I need some help setting up a survey database.

    As of right now I want the database to store codes in one table.
    Codes
    CodeName
    CodeValue
    Description
    EntryDate
    EnteredBy
    Notes

    Second table is a survey table with the questions to more than 1 survey
    Survey ID
    Survey Date - date survey created
    Survey Name
    Description
    Q1
    Q2
    .
    QEnd

    Third table is a answer table which stores multiple times a client answers just taken on different dates

    Answers Table
    Client ID - this links to a table called client which has info about client. This is a many relationship. These clients will take survey more than once.
    SurveyID- which I'm thinking needs to be linked to survey table.
    EntryDate-Date the survey has been entered
    A1
    A2
    .
    AEnd

    Please give me feedback because the questions has to match with answers some how when creating a survey form.

    Z

  2. #2
    I like Data Cubes too... Lauramc has a spectacular aura about Lauramc has a spectacular aura about Lauramc's Avatar
    Join Date
    Mar 2008
    Location
    Far Far Away
    Posts
    387
    Real Name
    Laura
    Rep Power
    5

    Well, off the top of my head here are my thoughts:

    You'll want a client table that contains your client data, and this would related to your clientSurvey table on the client id (or whatever primary key you choose in the client table).

    Then you'll need a survey table that contains one survey ID for each survey and details about that survey like subject and date etc.

    You may want a many to many table of clients and surveys (say a clientSurvey table).

    You'll need a Question table. Each new question gets an ID number.

    Finally you may want a many to many table to contain the relationships between the Questions and the Survey they belong to. This might be called a SurveyQuestion table.

    Just my thoughts. Obviously you need to work out the design to meet your needs.
    "The Enrichment Center is required to remind you that first you will be baked, then there will be cake." - GLaDOS

  3. #3
    Barn Regular boblarson will become famous soon enough boblarson's Avatar
    Join Date
    Jul 2008
    Location
    Portland, Oregon
    Posts
    66
    Blog Entries
    1
    Real Name
    Bob
    Rep Power
    4

    Zaheir:

    I think you really need to understand normalization of data in order to design the proper structure. It is obvious from your post that you do not.

    I would suggest reading this and trying to understand it before going further:
    Data Normalization
    Bob Larson
    Access MVP (2008-2009, 2009-2010, 2011-2012)

    Free samples and tutorials: http://www.btabdevelopment.com



  4. #4
    Barn Newbie Ziggy is an unknown quantity at this point Ziggy's Avatar
    Join Date
    Feb 2009
    Posts
    22
    Rep Power
    4

    If I understand correctly I see that in a ClientTable there is one unique client and ClientID is primary key.

    In the table ClientSurveyTable there is also ClientID which would store the answers and should it be related to table Client by ClientID?

    Therefore I see that between ClientTable and ClientSurveyTable there is a one to many relationship.

    Then having a QuestionTable each question will have its own ID which is an AutoNum primary Key. That also has a field in the table called SurveyID.

    We then have another table called SurveyQuestionTable which will have SurveyID, Survey Name, DateCreated etc.

    To my understanding the the SurveyQuestionTable will be connected to Survey ID in the QuestionTable which will be a 1 to many relationship.

    Is there any way the SurveyQuestionTablee would be connected to the ClientSurveyTable?

    I greatly appreciate anyones help.

    Z

  5. #5
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    Here's an example of a survey database:

    Surveys
    SurveyID - int - PK
    Title - varchar(100)
    Description - varchar(255)
    DateCreated - datetime

    Questions
    QuestionID - int - PK
    SurveyID - int (relationship with Surveys table)
    Question - varchar(255)

    ClientAnswers
    ClientAnswerID - int - PK
    SurveyID - int (relationship with Surveys table)
    QuestionID - int (relationship with Questions table)
    ClientID - int (relationship with Clients table)
    Answer (depending on the type of questions, this could be an int field used as a relationship to a possible answers table if using a multiple-choice-type survey)
    EntryDate - datetime

    This is just an idea...and depending on the type of questions the survey allows, it could be much different.
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


  6. #6
    Barn Newbie Ziggy is an unknown quantity at this point Ziggy's Avatar
    Join Date
    Feb 2009
    Posts
    22
    Rep Power
    4

    I would like to ask shouldnt every table have a primary key in sql server if so how do add an auto number to sql server

  7. #7
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    Quote Originally Posted by Zaheir View Post
    I would like to ask shouldnt every table have a primary key in sql server if so how do add an auto number to sql server
    Typically, tables should have a field that holds a unique value. However, there are cases where it is not necessary. For example, if you had a table for users and a table for usergroups, you would have a third table to link multiple users to multiple groups. This third table would not need a primary key.

    In SQL Server, to add an "auto number" field, simply set the "Identity Specification" property to "Yes" and under that, set "(Is Identity)" to "Yes". You also have options to set how much the identity should increment and the seed value.
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


  8. #8
    Barn Newbie Ziggy is an unknown quantity at this point Ziggy's Avatar
    Join Date
    Feb 2009
    Posts
    22
    Rep Power
    4

    Help is greatly appreciated

    I try to mimic the example given with access database but sql doesnt let you join fields that dont have primary key. I am trying to use the db schema that Jmurrayhead

    Z

  9. #9
    Lightning Master AOG123 is a jewel in the rough AOG123 is a jewel in the rough AOG123 is a jewel in the rough AOG123 is a jewel in the rough AOG123's Avatar
    Join Date
    Mar 2008
    Location
    Fortress Of Solitude
    Posts
    394
    Rep Power
    7

    Where is the db schema?

    Have you thought about using foreign keys that relate primary keys,. that would appear to be necessary in this example.
    If i helped you, make me famous by clicking the

  10. #10
    Barn Newbie Ziggy is an unknown quantity at this point Ziggy's Avatar
    Join Date
    Feb 2009
    Posts
    22
    Rep Power
    4

    help plz

    My skema is on the page one of this thread. I am using SQL instead of access and you have to have a primary key in order to connect fields. Not like your example in access that is missing primary keys. What happens after i place an auto num primary on both tables sql doesnt allow you to relate them together such as answer to answer and queston to question from the Answer and Results table of your example.

    I appreciate your help. May be i am not clear.

+ Reply to Thread
Page 1 of 2 1 2 LastLast

Similar Threads

  1. Table troubles
    By bryceowen in forum HTML & CSS Help
    Replies: 7
    Last Post: February 6th, 2009, 12:02 PM
  2. Table border help
    By Rebelle in forum HTML & CSS Help
    Replies: 3
    Last Post: December 5th, 2008, 12:43 PM
  3. Design/Logic permission and no permission setup
    By Rebelle in forum ASP Development
    Replies: 2
    Last Post: November 6th, 2008, 09:50 AM
  4. Relational table methods
    By dr_rock in forum Database Design Help
    Replies: 5
    Last Post: October 24th, 2008, 04:25 PM
  5. Form Design: Label in Header Control in details
    By nboscaino in forum Microsoft Access
    Replies: 2
    Last Post: August 28th, 2008, 07:03 PM

Bookmarks

Posting Permissions

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

SEO by vBSEO