I am making an web application for an iOS app I made. I want to administrate the questions in the application that I have made, but now I also want users to have the oppertunity to submit questions to the web application. However, the questions from the users can’t just be added to the list becaus I want to approve that it is a valid question first.
I thought of making the following:
- A page where the users can register and submit a question.
- This is handled by a seperate backing bean (not the same as I use in the admin panel)
- The question is so passed to the EJB which again persist the question.
- Then I have a list of user submitted questions and I have the option to “Approve”, meaning that I will have the oppertunity to persist the question in the approved question table.
With this approach I must make a duplicate of the question table (as well as the answer and category table) and have a prefix or something (user_submitted_questions for example)
Is this a “good” way of doing it? Or can I do it better/more effcient?
I wouldn’t duplicate the entire question. Instead, try adding a
statusfield to the Question object. When questions come into the web application, they can be persisted with a SUBMITTED status. Once you review them, they can be updated to be either APPROVED or REJECTED. You can code your front-end to only show questions withstatus == APPROVEDon the public view.This avoids the overhead of maintaining 2 question tables/objects (as you evolve the system, now you’ll only need to maintain 1 table/object as you add/remove fields). The performance of approving a question should improve as well since it is just updating a single field rather than inserting a whole new row. If your table grows too quickly, you can always build an archive (or truncate) job that purges or moves rejected questions.