I need database for Bitcoin blockchain data. Previously I have two main tables : general and detail in SQL database. These tables were tables of transactions. Now I want table of address, because main search would be search by address. (unless is possible more than one index)
First approach is:
adr = address
txh = transaction hash
bh = block_height
bt = block_time
xtx = indx_tx = index transaction in block
cin = count_in
cout = count_out
xio = indx_io = index input/output in transaction

             family general                           family detail
adr|| txh | bh  | bt | xtx| fee | size| cin | cout || type | xio |amount
-----------------------------------------------------------------------
aaa||  x  | 17  | t17|  5 | 200 | 450 |  5  |  2   ||  0   |  2  | 10
   ||     |     |    |    |     |     |     |      ||  0   |  3  |  1
   ||     |     |    |    |     |     |     |      ||  1   |  0  |  5
   ||-----------------------------------------------------------------
   ||  y  | 20  | t20|  1 | 100 | 250 |  1  |  1   ||  0   |  0  | 10
   ||-----------------------------------------------------------------
   ||  z  | 22  | t22| 100|     |  50 |  10 |  20  ||  1   |  5  | 10
   ||     |     |    |    |     |     |     |      ||  1   |  6  | 10
----------------------------------------------------------------------
abb|| x   | 17  | t17|  6 | 210 | 400 |  2  |  2   || 1    |  0  | 5
   ||     |     |    |    |     |     |     |      || 1    |  1  | 5
   ||-----------------------------------------------------------------
   || x2  | 39  | t39|   0|     | 100 |   0 |  1   ||  1   |  0  | 12

this nested approach has disadvantages:
adr is unique and if I add next row, old row will be replaced.

I am training after https://github.com/borneq/thrift-exercises/blob/master/cpp/Hbase/DemoClient.cpp
there are issues:
- only families are created at start, columns are created when mutateRow:
    mutations.push_back(Mutation());
    mutations.back().column = "entry:num";
    mutations.back().value = boost::lexical_cast<std::string>(i);
cells are filled by string, not bytes, this has disadvantages:
- hashes have 32 raw bytes or 64 hex strings
- numbers must be saved as strings like 0000000004, this disable advantages numbers as integers.

My questions:
- how put data as bytes?
- is possible make table as transaction (not address) table and efficient search address?
- unique key can be more than one column?
- better are two tables (general, detail) or one table with two families?
- in DemoClient.cpp were problems with mutation to empty value - how save space for rows like:
   ||     |     |    |    |     |     |     |      ||  0   |  3  |  1
where are empty value because its value are redundant with first row.

Reply via email to