Download Table-based approach

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Business intelligence wikipedia , lookup

Operational transformation wikipedia , lookup

Database wikipedia , lookup

Data vault modeling wikipedia , lookup

Entity–attribute–value model wikipedia , lookup

Versant Object Database wikipedia , lookup

Clusterpoint wikipedia , lookup

Relational model wikipedia , lookup

Database model wikipedia , lookup

Transcript
Comparison of table-based and JSON-based chaincode
Table-based approach
JSON-based approach
Relational database table metaphor
NoSQL metaphor: key/value (LevelDB), document db (CouchDB)
Requires schema definition up front
Does not require schema definition step
Difficult to change schema in later chaincode versions
Easy to add JSON fields in later chaincode versions
Does not support hierarchical data
Supports hierarchical data
Not aligned with underlying ledger data layer, therefore
metaphor inconsistent with fabric functional capabilities
- e.g. Can’t query on table columns as expected
Aligned with underlying ledger data layer, therefore
metaphor consistent with fabric functional capabilities
- Query based on key or partial key range
More code layers, more complex chaincode
Less code, use built-in structure  JSON marshaling
Compatible with next-generation ledger capabilities
- Query ledger on ANY field, within or outside chaincode
- Powered by JSON state database (CouchDB)
Proposal
• Remove Table API from Hyperleger Fabric in v1.
• The v0.5/v0.6 Psuedo-table API does not map well to current or next generation
Fabric capabilities
• Project teams have been confused and frustrated with table API limitations
• Encourage all new chaincode to use JSON-based data structures
• Additional query benefits when using CouchDB state database
• Provide JSON-based samples to help community update table-based chaincode
• Initial sample: https://github.com/denyeart/table_to_json/blob/master/chaincode/table_to_json_chaincode.go
• In the future Fabric may add support for relational state databases
• At that time it will make sense to introduce a ‘real’ table API without the limitations
of the current psudo-table API
Side-by-side chaincode comparison of
Table approach and JSON approach
Setup
Table-based approach
Define schema and persist to ledger
JSON-based approach
Annotate chaincode structures for JSON marhsaling
Add marble
Table-based approach
Insert marble row into ledger table
JSON-based approach
Add marble JSON to ledger, use objectType as key namespace
Get marble
Table-based approach
Get marble based on key columns
JSON-based approach
Get marble based on compound key
Scenario: Query for blue marbles
Enabled in key/value state database by using an intelligent compound key ‘Marbles:color:name’ and doing partial range key query on ‘Marbles:color’ only
Table-based approach
GetRows() using first N key columns (left to right)
JSON-based approach
partialCompoundKeyQuery() using first N keys (left to right)
Proposed: New chaincode APIs
PutStateJSON() / GetStateJSON()
• Allow chaincode developer to distinguish between binary blobs and JSON-based ledger variables (rather than auto-detect)
PutStateJSONWithAttachments() / GetStateJSONWithAttachments()
• Store documents on the ledger with queryable JSON header info
CreateCompoundKey()
• Utility function to format compound keys consistently (see next)
PartialCompoundKeyQuery()
• Utility function to assist with partial key queries (makes assumption about compound key format)
Add objectType to all Put/Get API signatures, to enforce namespacing of object types within chaincode?
Equivalent of ‘tableName’ when using table-based API.