Naveed Cheema Naveed Cheema - 1 month ago 9x
SQL Question

Designing Feedback database table

What attributes should be in the Feedback table?

First of all I do not require any login for feedback. So I'm putting the following column in my table:

For Example

  1. Subject = that about what is the purpose of feedback.

  2. message = description of subject.

  3. contact Number

  4. Email = to contact the user or replay the answer to subject

  5. Name = for calling the user purpose


    Do I need any primary key in my table? And if so, why do I need the primary key? Any suggestions?


Primary is used to identify a particular row in your table.

Say if you are getting multiple feed back from the same customer,you can't identify them from the fields that you mentioned. You can just list out it based on the name or email of the customer. If there is an ID (primary key) you can tell that this is the first feedback that we received from a particular customer or something like that. Again its better to add a 'feedback date' as a field in your table so that you can track the feedbacks.

Here is the sample schema.

CREATE TABLE dbo.Feedback
  ([ID] INT IDENTITY(1,1) PRIMARY KEY, --Primary key of your table
   [Subject] VARCHAR(500),
   [Message] VARCHAR(MAX),-- limit the datatype as per your allowed characters
   [Name]  VARCHAR(150),
   [Contactnumber] VARCHAR(20),
   [Email] VARCHAR(150),
   [ReceivedDate] DATETIME Default(GETDATE()) --the date you received the feedback