简体   繁体   English

允许管理员创建新列?

[英]Allow admin to create a new column?

What I'm trying to do is allow an admin to create a questionnaire. 我正在尝试做的是允许管理员创建调查表。 Every time a user writes a review for a product they must also fill out a questionnaire. 每次用户为产品撰写评论时,他们还必须填写调查表。 This is for an educational simulation. 这是用于教育模拟。

I'm currently using Visual Studio an am developing an ASP.NET MVC3 Website in C#. 我目前正在使用Visual Studio,正在用C#开发ASP.NET MVC3网站。 I also use/have SQL Server 2008 and SQL Management Studio. 我也使用/拥有SQL Server 2008和SQL Management Studio。

I'm having trouble thinking about the best way to do this. 我在考虑最好的方法时遇到了麻烦。

Right now my solution is to say "You can ask up to 10 questions" and then have a 'Questions' table in my database and store all answers with each review and have 10 'Answer' columns per review. 现在,我的解决方案是说“您最多可以提出10个问题”,然后在我的数据库中有一个“问题”表,并存储每个评论的所有答案,每个评论有10个“答案”列。

What would be even better is if I can somehow allow the admin to ask as many questions as they'd like and add more columns to my database table as needed. 更好的是,如果我能以某种方式允许管理员问他们想要的问题,并根据需要向我的数据库表中添加更多列。 Is there any way to do this? 有什么办法吗?

Or is there a better way to design my database? 还是有更好的方法来设计数据库?

Just give yourself a child table Answers that has a foreign key to Questions . 只需给自己一个子表Answers ,该表具有Questions的外键。 Then you can have as many answers as you want. 然后,您可以根据需要获得尽可能多的答案。

That isn't very normalized. 这不是很正常。

You should have a table with one record for each question/answer pair. 您应该有一张表格,其中每个问题/答案对都有一条记录。

You'll want to have a table to store the Questions , and a separate table to store the Answers . 您将需要一个表来存储Questions ,以及一个单独的表来存储Answers The Answers table can then have a foreign key to the record in Questions it's answering. 然后, Answers表可以在要回答的Questions有一个外键。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 DataFormats.GetFormat 是否允许我创建新的私有格式? - Does DataFormats.GetFormat allow me to create a new private format? 允许Web用户在项目中创建新的.Net页面 - Allow a Web User to Create a New .Net Page in the Project 以编程方式登录到Google Admin Directory,以创建新用户 - Programmatically login to Google Admin Directory in order to create new users 如何创建新的gridview列类型 - HOW TO create new gridview column type 只允许管理员删除文件? - Allow only Admin to delete a file? 通过接受datepicker值作为列名在表中创建新列 - Create new column in the table by accepting datepicker value as column name 创建新的 C# DataTable 列作为现有列的函数 - Create new C# DataTable Column as a function of Existing Column 如何在运行时允许用户创建新的 Picturebox Visual Studio C# Windows Forms - How to at runtime allow a user to create a new Picturebox Visual Studio C# Windows Forms Apps 具有身份验证的MVC 5 C#标准项目-如何从管理员视图创建新用户 - MVC 5 C# Standard Project with Authentication - how to create new users from an admin view 如何使用现有站点的管理面板创建新的子域网站 - How to create new sub domain website using admin panel of existing site
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM