简体   繁体   中英

Store lists/checklist into MySQL database

I want to make a demo application that is able to ask a user if he/she has followed the correct methods to build an item.

I have created a 'checklist' for the user to fill in as he/she builds the item. For example some of the questions could be:

  1. Have you received the correct parts?
  2. Are the parts in good condition?
  3. Are you building a chair?
  4. Do you have the correct specifications for the chair?
  5. ...
  6. ...

...

And so on...

So these questions have yes/no answers only. My plan was to create a table and call each column by the questions' number. So column 1 will be called '1' and it's the first question. Column 2 will be called '2' and it's the second question and so on.

So this table will be called Chair inspection. I then have another table called Table inspection with its own set of checklist questions.

This data is captured using an android application. The development of the application is done. Just need advice on the database part.

Is this the correct approach to storing the user's inputs?

在此处输入图像描述

I advice you have three tables, one for the questions, the other for the users who will be answering those questions and the last one is for the answers, then you establish the relationship between those three tables. That means Many users can answer many questions. Therefore there will be many to many relationship between users and questions. Then there will be relationship between questions and answers and answer with the users who responded to the questions.

I think that way you will be able to avoid redundancy and simplify the process of updating, and retrieving you data.

A normalised schema might be as follows (incomplete, and ignoring 'tables' for the time being):

inspection
inspection_id* item inspected_by date

inspection_detail
inspection_id* checklist_id* status 

* = (component of) PRIMARY KEY 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM