CooperDB

Relational Database Management built on top of IPFS/Filecoin.

Inspiration

To onboard more developers into the web3 space we need to provide tools that most developers are familiar with. Relational databases are the most widely used database option in development of systems and are a very powerful tool for handling data.

Although there exist database options on IPFS like OrbitDB which handle key-value stores, we do not have a robust relational database framework in the web3 space which results in may developers using the traditional web2 database options like MySQL and Postgres.

Demo Video

DEMO

How it works

flowchart TD
    A[APP] --> B[APPLICATION API]
    B --> C[Cooper Query Language Parser]
    C --> D[DB manipulation]
    D -- Commit --> E[IPFS Storage Layer]
    E -- Load DB Instance --> D
    D --> C
    B -- Return Values --> A

We are working on creating a subset of SQL called CooperQL which will act as a Domain Specific Language for the CooperDB frame work. After every request which changes the state of the data loaded from IPFS a new commit is done and the CID is updated.

Available database queries for the current iteration:

  • create database
  • create table
  • all CRUD operations on rows
  • Joins (inner, outer, left, right)

Example request to create a table (Code is well documents, please browse through for more examples):

{
    "query": "create_table"
    "database_name": "cooperDB_demo",
    "name": "addresses",
    "columns": [
                    { 
                        "name": "name",
                        "type": "string",
                        "primary_key": True, 
                        "unique": True, 
                        "foreign_key": 
                            {
                                "table": "clients",
                                "column": "name"
                            }
                    },
                ]
}

Future developments

  • Data encryption
  • Make CooperDB open to the public
  • Improve CooperQL
  • Handle more complex predicates
  • Allow for creation of user defined functions and stored procedures

Challenges faced

Mainly, creating a Lexer for parsing requests.

Running the project

  • Requires Python 3.6+
  • API KEY from Tatum for IPFS data storage
  1. Clone the repo.
git clone https://github.com/IKalonji/CooperDB.git
  1. Insert API KEY into ipfs_requests.py.

  2. Run test_script.py.

  3. Now you can play around with the different functionalities.

Acknowledgements

  • IPFS/Filecoin
  • Devpost

Licenses

The project is open source under the MIT License, please see the license file.

linkedin-url

Built With

Share this project:

Updates