Database structure note-breaking

0

I have a note assignment system where it is allowed to reply, replica and / or rejoinder, what is the best way to store it in the database?

  • Create three tables ( contestacao , replica , treplica )
  • Create a table with all 3 fields
  • Create a table with the tipo
  • asked by anonymous 10.03.2014 / 01:34

    1 answer

    3

    It depends on what you want.

    Create three tables (contestation, replica, treplica)

    This allows you to enter multiple contests, replicas, and replicas for each note (which I believe is not your goal). The control by the system is greater, since there are 3 tables, and if it is the case to bring the records in a single query, you can force the system to use unions , which is not good for performance. Great for cases where interesting to access only one table of each type at a time.

    Create a table with all 3 fields

    For the scope of business, I think it is the most appropriate, considering that each note may have only one answer, one reply and one rejoinder. It's also the simplest to get and upgrade, but it does not fit multiple records of contests, replicas, and replicas.

    Create a table with type field

    This case is interesting when you want to save on the number of queries and minimize the amount of joins used by the system. It is also in case your system allows for a variable amount of contestations, replicas, and replicas. It may be necessary to add an index by type, which makes the table larger in the database.

        
    10.03.2014 / 01:40