samedi 23 novembre 2019

Best design for two different tables with 90% same columns

I have a feature_values table which contains data stored by users: they can edit and update this table.

#user_feature_values
user  | year  |  quarter | gdp | other 
---------------------------------------
1       2018      Q1        1.5    1.2
1       2018      Q2        1.6    1.5
5       2017      Q1       -1.2    1.0
.......................................
.............
4       2017      Q4        1.0    2.5

There is another similar table which stores default values. Users can't edit this.

#default_feature_values
country  | year  |  quarter  | gdp  | other 
---------------------------------------
5          2018      Q1        1.8    2.0
10         2015      Q2        1.4    1.2
120        2017      Q3       -1.2    1.0
.......................................
.............
115        2016      Q4        1.5    2.15

Current scenario: Once the user is created, I am literally copying the default values into #user_feature_values based on the user's country. So that they can edit the default values in their table with their own values. At a later time, they can opt for default values; which are copied to #user_feature_values table from #default_feature_values table.

Is this a bad design?

How well this can be implemented?

Aucun commentaire:

Enregistrer un commentaire