Insert historical values to statistics table?

Can someone please help me understand how the tables in the database refer to the statistics?

Discussion continued in the Energy category