Search code examples
mysqlsqlnormalization

Proper way to store requests in Mysql (or any) database


What is the "proper" (most normalized?) way to store requests in the database? For example, a user submits an article. This article must be reviewed and approved before it is posted to the site.

Which is the more proper way:

A) store it in in the Articles table with an "Approved" field which is either a 0, 1, 2 (denied, approved, pending)

OR

B) Have an ArticleRequests table which has the same fields as Articles, and upon approval, move the row data from ArticleRequests to Articles.

Thanks!


Solution

  • Since every article is going to have an approval status, and each time an article is requested you're very likely going to need to know that status - keep it inline with the table.

    Do consider calling the field ApprovalStatus, though. You may want to add a related table to contain each of the statuses unless they aren't going to change very often (or ever).

    EDIT: Reasons to keep fields in related tables are:

    • If the related field is not always applicable, or may frequently be null.
    • If the related field is only needed in rare scenarios and is better described by using a foreign key into a related table of associated attributes.

    In your case those above reasons don't apply.