Bitcoin Forum
December 05, 2016, 08:48:41 AM *
News: To be able to use the next phase of the beta forum software, please ensure that your email address is correct/functional.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: SQL schema for the blockchain ?  (Read 2920 times)
dogisland
Sr. Member
****
Offline Offline

Activity: 261



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. 
1480927721
Hero Member
*
Offline Offline

Posts: 1480927721

View Profile Personal Message (Offline)

Ignore
1480927721
Reply with quote  #2

1480927721
Report to moderator
1480927721
Hero Member
*
Offline Offline

Posts: 1480927721

View Profile Personal Message (Offline)

Ignore
1480927721
Reply with quote  #2

1480927721
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1480927721
Hero Member
*
Offline Offline

Posts: 1480927721

View Profile Personal Message (Offline)

Ignore
1480927721
Reply with quote  #2

1480927721
Report to moderator
1480927721
Hero Member
*
Offline Offline

Posts: 1480927721

View Profile Personal Message (Offline)

Ignore
1480927721
Reply with quote  #2

1480927721
Report to moderator
1480927721
Hero Member
*
Offline Offline

Posts: 1480927721

View Profile Personal Message (Offline)

Ignore
1480927721
Reply with quote  #2

1480927721
Report to moderator
genjix
Legendary
*
expert
Offline Offline

Activity: 1232


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
Sr. Member
****
Offline Offline

Activity: 261



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


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

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!