Following the analogy that a blockchain is a kind of database, I'm trying to understand how my data should be structured and stored on the blockchain.
I've read about writing contracts in solidity and I see that contracts can contain complex data types such as mappings, arrays and struts, etc.
Should I store database type table data, inside one of these inside a contract, or should I create many contracts of the same type and store a row of data in each?
Perhaps an example will help explain, say I want to store relationships between user accounts, would I create a 'table' contract as follows:
pragma solidity ^0.4.0;
/// @title Company roles.
contract CompanyRole {
mapping(address => address) public directors;
}
or a 'row' contract:
pragma solidity ^0.4.0;
/// @title Company roles.
contract CompanyRole {
address person; // company the role is valid for
address company; // company the role is valid for
uint type; // the type of role
}
It would be helpful to know the pros and cons of both approaches, or others, including cost implications.
Basically my question is where should table data be stored?