Bitcoin Forum
December 12, 2024, 04:47:06 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: SQL schema for the blockchain ?  (Read 3603 times)
dogisland (OP)
Sr. Member
****
Offline Offline

Activity: 262
Merit: 250



View Profile
October 31, 2011, 06:16:31 PM
 #1

I'm going to store the blockchain in a SQL database.

Has anyone got any experience of this or even a schema they can share ? What I've got so far looks like this.

Code:
CREATE TABLE blocks ( hash CHAR(32) NOT NULL CONSTRAINT blocks_pk PRIMARY KEY,chainWork BLOB NOT NULL,height BIGINT NOT NULL,heade
r BLOB NOT NULL);
CREATE TABLE settings ( name VARCHAR(32) NOT NULL CONSTRAINT settings_pk PRIMARY KEY,value BLOB);
CREATE TABLE transactions ( hash TEXT NOT NULL CONSTRAINT transactions_pk PRIMARY KEY,ver INTEGER NOT NULL,vin_sz INTEGER NOT NULL
,vout_sz INTEGER NOT NULL,lock_time INTEGER NOT NULL,size INTEGER NOT NULL);
CREATE TABLE transactions_input ( hash_parent_tx TEXT NOT NULL,script_sig TEXT NOT NULL);
CREATE TABLE transactions_output ( hash_parent_tx TEXT NOT NULL,value REAL NOT NULL,script_pub_key TEXT NOT NULL);


I'm going to use BitcoinJ to download the chain as it's quite easy to create a new DataStore. I'll open source the result so if anyone has any requirements for this please let me know.

What I'm looking to do is gather data to make payment transactions for arbitrary public keys. 
genjix
Legendary
*
expert
Offline Offline

Activity: 1232
Merit: 1076


View Profile
October 31, 2011, 06:26:00 PM
 #2

https://bitcointalk.org/index.php?topic=38246.0

https://gitorious.org/libbitcoin/libbitcoin/blobs/master/bitcoin.sql
dogisland (OP)
Sr. Member
****
Offline Offline

Activity: 262
Merit: 250



View Profile
October 31, 2011, 07:40:12 PM
 #3


That's why I love this forum. Thanks.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!