Making PostgreSQL database data visible or not, without deleting, is it possible?

1

I have an application where in addition to registering and consulting clients, it allows to issue reports with the information of the clients, the problem is that many of these customers already registered do not have more importance for the current reports.

Is it possible to make bank data inaccessible without deleting it?

    
asked by anonymous 01.12.2016 / 14:43

2 answers

3

You can do this in the application. You can create a column with a status to indicate that the line is off and not show anywhere. Or you can use an existing column that indicates this. Obviously if you do not have any data that can be used as a criterion for deciding what to show or not, there is no way.

You can also make a view , but the hits would have to be accessed by view , if you access outside it, access the data you do not want.

In thesis could use a conditional index (partial / filtered), but again, would have to access by it to consider the filter.

Usually this should be planned in the solution as a whole. That is, does not have an automatic way to resolve this .

I imagine you need to keep this data to ensure referential integrity, so any solution to move the data elsewhere does not resolve it.

    
01.12.2016 / 14:53
2

I would have some possible solutions:

  • Create a column to define whether the data is visible or not, then filter through this column.

  • Create a table with the ids of the records that should or should not be visible, and join that table or exists if not too much data.

  • Create a "backup" table and move to it all the data you no longer want to be visible by removing them from the main table, but without deleting them. This would only work if there is no FK with another table, which does not allow deleting records.

Here are some ideas you can solve.

    
01.12.2016 / 14:51