Table Design

Next to the key value store, Kooboo provide a table base table database, similar as the table in SQL database. The table schema at Kooboo is dynamic. 

Dynamic table structure

You do not need to create a table or create table columns before using the table. While you are using it, the database table schema will be built for you according to the data inserted. 

Below code reads data from http querystring or form. If the data is provided, it will get or create a table and insert the data. 

If the table named "newtable" does not exist, it will be created. If the table column "name" and "value" does not exist, it will be created. 

<script engine="kscript">
        var name = k.request.name; 
        var value = k.request.value; 
        if (name)
        {
            var table = k.database.getTable("newtable"); 
            var obj ={}; 
            obj.name = name; 
            obj.value = value; 
            table.add(obj);  
        }
</script>

Define table schema

You do can predefine table and schema, just like SQL database.

Go to "Storage" -- "Database".

Create a new table and click "Edit" in the table row to open that table schema design page. 

Click "New column", give it a name and select the control type. 

Save and go back to table list page, click one the table name. 

Open the table data management page. 

You can manually add table data there.