+ Reply to Thread
Page 2 of 2 FirstFirst 1 2
Results 11 to 18 of 18

Thread: Database table design

  1. #11
    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

    In SQL Server Management Studio, create a database called SurveyDatabase. If you don't want to use that name, change the first line in the below code to say "Use [yourdatabasename]. Then, click "New Query" and execute the following in that window:

    Code:
    Use [SurveyDatabase]
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Surveys]') AND type in (N'U'))
    BEGIN
    CREATE TABLE [dbo].[Surveys](
     [SurveyID] [int] IDENTITY(1,1) NOT NULL,
     [Title] [varchar](100) NOT NULL,
     [Description] [varchar](255) NOT NULL,
     [DateCreated] [datetime] NOT NULL,
     CONSTRAINT [PK_Surveys] PRIMARY KEY CLUSTERED 
    (
     [SurveyID] ASC
    )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
    ) ON [PRIMARY]
    END
    GO
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Questions]') AND type in (N'U'))
    BEGIN
    CREATE TABLE [dbo].[Questions](
     [QuestionID] [int] IDENTITY(1,1) NOT NULL,
     [SurveyID] [int] NOT NULL,
     [Question] [varchar](255) NOT NULL,
     CONSTRAINT [PK_Questions] PRIMARY KEY CLUSTERED 
    (
     [QuestionID] ASC
    )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
    ) ON [PRIMARY]
    END
    GO
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ClientAnswers]') AND type in (N'U'))
    BEGIN
    CREATE TABLE [dbo].[ClientAnswers](
     [QuestionID] [int] NOT NULL,
     [ClientID] [int] NOT NULL,
     [Answer] [varchar](255) NOT NULL,
     [EntryDate] [datetime] NOT NULL
    ) ON [PRIMARY]
    END
    GO
    IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Questions_Surveys]') AND parent_object_id = OBJECT_ID(N'[dbo].[Questions]'))
    ALTER TABLE [dbo].[Questions]  WITH CHECK ADD  CONSTRAINT [FK_Questions_Surveys] FOREIGN KEY([SurveyID])
    REFERENCES [dbo].[Surveys] ([SurveyID])
    GO
    IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ClientAnswers_Questions]') AND parent_object_id = OBJECT_ID(N'[dbo].[ClientAnswers]'))
    ALTER TABLE [dbo].[ClientAnswers]  WITH CHECK ADD  CONSTRAINT [FK_ClientAnswers_Questions] FOREIGN KEY([QuestionID])
    REFERENCES [dbo].[Questions] ([QuestionID])
    
    This should create the database schema I showed you.
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


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

    schema

    The database schema earlier also consisted of an answers tables to store the answers can you incorporate a table answers into the script? Also I would like to know like for access you can see an entity diagram. Is there a way I can see in SQL server how the tables are linked? I think you created some linkage in the script that you helped me with.

    Im new to SQL server. I appreciate your help

    Thanks.

  3. #13
    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
    The database schema earlier also consisted of an answers tables to store the answers can you incorporate a table answers into the script? Also I would like to know like for access you can see an entity diagram. Is there a way I can see in SQL server how the tables are linked? I think you created some linkage in the script that you helped me with.

    Im new to SQL server. I appreciate your help

    Thanks.
    The ClientAnswers table is included in the above script.

    To see the linking between tables, in SQL Server Management Studio, click the "Database Diagrams" node for the database. It will prompt you to create them, so click "Yes". After this you should be able to see all the table details and how they are linked.
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


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

    diagram

    I was thinking of a table that will have all possible answers because ClientAnswers actually stores the answers but basically it will serve as a lookup table. If I understand correctly you dont have to link this kind of table? It current shows no database diagram. I was thinking that the script had a created some type of linkage which is why I wanted to see how they were linked. There is a section for database diagram but no plus sign to the left.

    Thanks

  5. #15
    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

    If you're only ever going to need a multiple-choice style survey, then that will be easy. If you have other requirements, then it will be a little more difficult. Do you only need multiple-choice?

    As for the database diagram, you need to click the folder and then you will get a prompt to create the diagram. Click "Yes" on this prompt.
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


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

    multiple choice

    it will be all multiple choice but just many different surveys in which each survey has diff ques and many questions have different answer choices.

  7. #17
    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

    Quote Originally Posted by Zaheir View Post
    it will be all multiple choice but just many different surveys in which each survey has diff ques and many questions have different answer choices.
    Hi, I don't mean to be rude, but allot of ideas have been given to help you achieve what you want?

    Others here may disagree but i believe your employer may find it more beneficial paying a professional to do this.

    It will certainly cost more by time in the long run for you to take weeks / months over. I assure you it will most likely end up a inferior application which may not even work.

    In the mean time i sugest you practice your skills with something more simple.
    If i helped you, make me famous by clicking the

  8. #18
    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

    So create a table called "Answers" with the following fields:

    AnswerID int - PK
    QuestonID int (related to Questions table)
    Option varchar(100) (answer text to be displayed to user)

    After you save this table, click the relationships icon and relate it to the AnswerID field in the ClientAnswers table.

    I do agree with AOG, though. You really need to practice this. We aren't going to keep giving you the answers. You will have to learn it eventually.
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


+ Reply to Thread
Page 2 of 2 FirstFirst 1 2

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