doumianfeng5065 2016-07-04 03:00 采纳率: 0%
浏览 21
已采纳

多个mysql表与单个表设计

I'm looking into building a small survey system and i was wondering what would be the best design for the database based on: Each question can have a certain type of form for submit the answer.

  • Checkbox fields
  • Radio fields
  • input field
  • dropdown field

At first i was thinking since i'm using doctrine to create an entity for each type of field and save it into a separate table. The seconds option i was thinking would be to throw all the answers i set for a question in a single table and have a type field for the question where i tell it in the form of integer what form layout should load.

What do you think guys how should i do this ?

  • 写回答

1条回答 默认 最新

  • douchuntang2827 2016-07-04 03:13
    关注

    You should have one table Called Questions_Answer with entities as the number of options given for the checkboxes,radioField. Like Answer 1, Answer 2. And since the number of answer can vary, u can add the columns, using the ALTER TABLE Questions_Answer ADD column_name datatype

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部