E
E
easy_katka2020-08-24 09:37:43
PostgreSQL
easy_katka, 2020-08-24 09:37:43

How to store two states of one object in database?

There is an ad site, each phenomenon has a bunch of attributes depending on its category. To get online, each ad is checked by a moderator, if the user changes the ad, then it is again sent for moderation (version 2, let's say so) and the first one remains published on the site. Except duplication of tables what to store the Checked and Not checked infa what options are?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Korotenko, 2020-08-24
@firedragon

add
is_approved
version fields

select id, is_approved , version from board;

id | is_approved | version
-------------------------------
99 false 6
97 true 5

V
Vitsliputsli, 2020-08-24
@Vitsliputsli

Except duplication of tables what to store the Checked and Not checked infa what options are?

1) partitioning;
2) build indexes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question