1
I am working on a project using database in MySql
where some areas will be constantly fed generating a high number of records in a short time, such as an area for maintenance tickets. However, these data become obsolete as quickly as they are created and, after a certain time, no longer need to be used.
How can I set up a system to "archive" these records so that it no longer 'weighs' on the table?
I currently have a related table structure, where I relate customers and moderators to Ticket. Example:
tabela: Cliente
id | nome_cliente | sobrenome_cliente | etc..
tabela: Moderador
id | nome_moderador | cargo | etc..
tabela: Ticket
id | id_cliente | id_moderador | id_assunto | etc..
I could just create a new column arquivado
on the table Ticket
and use a SQL
that select all but the archived ones. But still they would be registered in that table.
Creating a new duplicate table from the Ticket table would be the solution? Ex.: ticket_arquivos
and then move the records to her?
Or what other method I can use to do this management?
Another question regarding this would be the identification of these obsolete data. I currently have the column status
and data_update
, where the status must be closed and the current date must be more than 15 days from the update date. It is possible to make this column data_update
automatically update regardless of the type of sql
that she suffers? Be one UPDATE
or a SELECT
?
Just moving on to a new one
tabela
already solve the case of performance (thinking long-term)? Or would it be necessary to move to another bank (with a structure copied as well)? Reading some materials after your reply I saw that some had a bench apart.– celsomtrindade
About using another database or not you should take into consideration whether you will access this data again frequently. If it will still be possible to carry out consultations, to issue reports, it is easier to leave everything in the same bank. If the data will simply be archived and will be accessed sporadically, then it is worth leaving in another bank. As for the performance, thinking about the execution time of the query, I think it would already solve, because it would be running the query in the table without the excess of records. As for the size of the bank and the storage issue, I couldn’t tell you.
– Emerson JS
Right, that’s what I figured. The answer is ok, but you could elaborate an example of the codes mentioned, at least from Trigger next to an update or as one would be next to a select, for example.
– celsomtrindade
Amended response with examples, check.
– Emerson JS
Perfect! Thank you so much for your help.
– celsomtrindade