SlicingDice Documentation

SlicingDice - The All-in-One Solution Documentation

Welcome to the SlicingDice documentation. You'll find comprehensive guides and documentation to help you start working with SlicingDice as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    Guides

4.2 Supported data types

Below we list all the data types supported by Attribute Columns and Event Columns:

Attribute Column data types

Event Column data types


String

You should use the string column to store text values, with one or more characters.
It is possible to store a single value or multiple values in the same column for an entity.

String columns should be used for text values that don't need to be unique. For example: name, product name, URL, city, state, country, hobbies, credit card label, car model, store name, manufacturer and so on.

Column limitations and restrictions

Below are the current limitations and restrictions for the string columns.

  • String values can have at most 1,000 characters.
  • Cannot insert empty strings, such as "".
  • String values are always stored in lowercase only.

Inserting data on a string column

Column configured to store the latest-value

Below you can find a data insertion example of one value to one entity (Entity1) on a string column (state), with storage parameter configured as latest-value.

Entities
State

Entity1

CA

INSERT INTO default ([entity-id], state) VALUES ("Entity1", "CA");
$ curl -X POST https://api.slicingdice.com/v1/sql \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/sql' \
    -d 'INSERT INTO default ([entity-id], state) VALUES ("Entity1", "CA");'
$ curl -X POST https://api.slicingdice.com/v1/insert \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
        "Entity1": {
            "state": "CA"
        }
    }'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY')

insert_data = {
    "Entity1": {
        "state": "CA"
    }
}

print(slicingdice.insert(insert_data))

import com.slicingdice.jslicer.SlicingDice;
import java.io.IOException;
import org.json.JSONObject;
import org.json.JSONArray;

public class Example {
    public static void main(String[] args) throws IOException {
        SlicingDice slicingdice = new SlicingDice("MASTER_API_KEY");

        JSONObject insertData = new JSONObject()
        .put("Entity1", new JSONObject()
            .put("state", "CA"));

        JSONObject result = slicingdice.insert(insertData);
        System.out.println(result.toString());
    }
}
require 'rbslicer'
slicingdice = SlicingDice.new(master_key: 'MASTER_API_KEY')

insert_data = {
    "Entity1" => {
        "state" => "CA"
    }
}

puts slicingdice.insert(insert_data)

const SlicingDice = require('slicerjs');

const slicingdice = new SlicingDice({masterKey: 'MASTER_API_KEY'});

const insertData = {
    "Entity1": {
        "state": "CA"
    }
};

slicingdice.insert(insertData).then((resp) => {
    console.log(resp);
}, (err) => {
    console.error(err);
});

<?php
use Slicer\SlicingDice;
$slicingdice = new SlicingDice(array("masterKey" => "MASTER_API_KEY"));

$insertData = array(
    "Entity1" => array(
        "state" => "CA"
    )
);

print_r($slicingdice->insert($insertData));
?>
using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var slicingdice = new SlicingDice(masterKey: "MASTER_API_KEY");

            var insertData = new Dictionary<string, dynamic>{
                {"Entity1", new Dictionary<string, dynamic>{
                    {"state", "CA"}
                }}
            };

            var result = slicingdice.Insert(insertData);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}
package main
import (
    "fmt"
    "github.com/SlicingDice/slicingdice-go/slicingdice"
)
func main() {
    keys := new(slicingdice.APIKey)
    keys.MasterKey = "MASTER_API_KEY"
    slicingdice := slicingdice.New(keys, 60)

    insertData := map[string]interface{}{
        "Entity1": map[string]interface{}{
            "state": "CA",
        },
    }

    fmt.Println(slicingdice.Insert(insertData))
}

Column configured to store a list-of-values

Below you can find a data insertion example of multiple values to one entity (Entity1) on a string column (page-content), with storage parameter configured as list-of-values.

Entities
Page-content

Entity1

welcome
slicingdice
data
warehouse
analytics
database
service

INSERT INTO default ([entity-id], [page-content]) VALUES ("Entity1", '["welcome","slicingdice","data","warehouse","analytics","database","service"]');
$ curl -X POST https://api.slicingdice.com/v1/sql \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/sql' \
    -d 'INSERT INTO default ([entity-id], [page-content]) VALUES ("Entity1", '["welcome","slicingdice","data","warehouse","analytics","database","service"]');'
$ curl -X POST https://api.slicingdice.com/v1/insert \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
        "Entity1": {
        "page-content": [
            "welcome",
            "slicingdice",
            "data",
            "warehouse",
            "analytics",
            "database",
            "service"
            ]
        }
    }'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY')

insert_data = {
    "Entity1": {
        "page-content": [
            "welcome", 
            "slicingdice", 
            "data", 
            "warehouse", 
            "analytics", 
            "database", 
            "service"
        ]
    }
}

print(slicingdice.insert(insert_data))

import com.slicingdice.jslicer.SlicingDice;
import java.io.IOException;
import org.json.JSONObject;
import org.json.JSONArray;

public class Example {
    public static void main(String[] args) throws IOException {
        SlicingDice slicingdice = new SlicingDice("MASTER_API_KEY");

        JSONObject insertData = new JSONObject()
        .put("Entity1", new JSONObject()
            .put("page-content", new JSONArray()
                .put("welcome")
                .put("slicingdice")
                .put("data")
                .put("warehouse")
                .put("analytics")
                .put("database")
                .put("service")));

        JSONObject result = slicingdice.insert(insertData);
        System.out.println(result.toString());
    }
}
require 'rbslicer'
slicingdice = SlicingDice.new(master_key: 'MASTER_API_KEY')

insert_data = {
    "Entity1" => {
        "page-content" => [
            "welcome", 
            "slicingdice", 
            "data", 
            "warehouse", 
            "analytics", 
            "database", 
            "service"
        ]
    }
}

puts slicingdice.insert(insert_data)

const SlicingDice = require('slicerjs');

const slicingdice = new SlicingDice({masterKey: 'MASTER_API_KEY'});

const insertData = {
    "Entity1": {
        "page-content": [
            "welcome", 
            "slicingdice", 
            "data", 
            "warehouse", 
            "analytics", 
            "database", 
            "service"
        ]
    }
};

slicingdice.insert(insertData).then((resp) => {
    console.log(resp);
}, (err) => {
    console.error(err);
});

<?php
use Slicer\SlicingDice;
$slicingdice = new SlicingDice(array("masterKey" => "MASTER_API_KEY"));

$insertData = array(
    "Entity1" => array(
        "page-content" => array(
            "welcome", 
            "slicingdice", 
            "data", 
            "warehouse", 
            "analytics", 
            "database", 
            "service"
        )
    )
);

print_r($slicingdice->insert($insertData));
?>
using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var slicingdice = new SlicingDice(masterKey: "MASTER_API_KEY");

            var insertData = new Dictionary<string, dynamic>{
                {"Entity1", new Dictionary<string, dynamic>{
                    {"page-content", new List<dynamic>{
                        "welcome", 
                        "slicingdice", 
                        "data", 
                        "warehouse", 
                        "analytics", 
                        "database", 
                        "service"
                    }}
                }}
            };

            var result = slicingdice.Insert(insertData);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}
package main
import (
    "fmt"
    "github.com/SlicingDice/slicingdice-go/slicingdice"
)
func main() {
    keys := new(slicingdice.APIKey)
    keys.MasterKey = "MASTER_API_KEY"
    slicingdice := slicingdice.New(keys, 60)

    insertData := map[string]interface{}{
        "Entity1": map[string]interface{}{
            "page-content": []interface{}{
                "welcome",
                "slicingdice",
                "data",
                "warehouse",
                "analytics",
                "database",
                "service",
            },
        },
    }

    fmt.Println(slicingdice.Insert(insertData))
}

String Event

You should use the string-event column to store text values that are associated with a date/time. Differently from string columns, string-event columns have different values throughout the time and tracking these changes over time is important. On the other hand, if your value is always constant or needs to be updated to keep the latest value, without caring for the time when it occurred, prefer using the string data type.

Examples of string-event usage include: browsed URLs, purchased products, completed shipments, login history, user searches, sensor status and so on.

The date component must follow the ISO 8601 format: YYYY-MM-DDThh:mm:ssTZ. Example: {% convert_date 'YYYY-MM-DDT10:35:23Z' '-1d' %}, you can also use a date with milliseconds values, but they will be automatically discarded. Example: 2017-06-01T10:35:23.954Z.
You are able to configure a timezone by replacing Z by +HH:MM or -HH:MM. Example: {% convert_date 'YYYY-MM-DDT10:35:23+03:00' '-1d' %} or {% convert_date 'YYYY-MM-DDT10:35:23-07:00' '-1d' %}.
Using Z is a shortcut to using UTC, such as in {% convert_date 'YYYY-MM-DDT10:35:23Z' '-1d' %}. However, it is important to know that the database will always store and fetch data in UTC format.

You may omit the date parameter when inserting data, but the database will use the current UTC timestamp. On the other hand, defining date gives you more control on the date being stored.

Column limitations and restrictions

Below are the current limitations and restrictions for the string-event columns.

  • String event values can have at most 1,000 characters.
  • String event date cannot be older than 12 years ago. So the earliest date allowed for today is: 2005-01-01.
  • Cannot insert empty strings, such as "".
  • String event values are always stored in lowercase only.

Inserting data on a string event column

Below you can find a data insertion example of one value to one entity (Entity1) on a string-event column (visited-pages).

Entities
Visited-pages

Entity1

/online-demo - {% convert_date 'YYYY-MM-DDT10:35:23Z' '-1d' %}

INSERT INTO default ([entity-id], [visited-pages.0.value], [visited-pages.0.date]) VALUES ("Entity1", '/online-demo', "{% convert_date 'YYYY-MM-DDT10:35:23Z' '-1d' %}");
$ curl -X POST https://api.slicingdice.com/v1/sql \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/sql' \
    -d 'INSERT INTO default ([entity-id], [visited-pages.0.value], [visited-pages.0.date]) VALUES ("Entity1", '/online-demo', "{% convert_date 'YYYY-MM-DDT10:35:23Z' '-1d' %}");'
$ curl -X POST https://api.slicingdice.com/v1/insert \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
        "Entity1": {
            "visited-pages": {
                "value": "/online-demo",
                "date": "{% convert_date 'YYYY-MM-DDT10:35:23Z' '-1d' %}"
            }
        }
    }'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY')

insert_data = {
    "Entity1": {
        "visited-pages": {
            "date": "{% convert_date 'YYYY-MM-DDT10:35:23Z' '-1d' %}",
            "value": "/online-demo"
        }
    }
}

print(slicingdice.insert(insert_data))

import com.slicingdice.jslicer.SlicingDice;
import java.io.IOException;
import org.json.JSONObject;
import org.json.JSONArray;

public class Example {
    public static void main(String[] args) throws IOException {
        SlicingDice slicingdice = new SlicingDice("MASTER_API_KEY");

        JSONObject insertData = new JSONObject()
        .put("Entity1", new JSONObject()
            .put("visited-pages", new JSONObject()
                .put("date", "{% convert_date 'YYYY-MM-DDT10:35:23Z' '-1d' %}")
                .put("value", "/online-demo")));

        JSONObject result = slicingdice.insert(insertData);
        System.out.println(result.toString());
    }
}
require 'rbslicer'
slicingdice = SlicingDice.new(master_key: 'MASTER_API_KEY')

insert_data = {
    "Entity1" => {
        "visited-pages" => {
            "date" => "{% convert_date 'YYYY-MM-DDT10:35:23Z' '-1d' %}",
            "value" => "/online-demo"
        }
    }
}

puts slicingdice.insert(insert_data)

const SlicingDice = require('slicerjs');

const slicingdice = new SlicingDice({masterKey: 'MASTER_API_KEY'});

const insertData = {
    "Entity1": {
        "visited-pages": {
            "date": "{% convert_date 'YYYY-MM-DDT10:35:23Z' '-1d' %}",
            "value": "/online-demo"
        }
    }
};

slicingdice.insert(insertData).then((resp) => {
    console.log(resp);
}, (err) => {
    console.error(err);
});

<?php
use Slicer\SlicingDice;
$slicingdice = new SlicingDice(array("masterKey" => "MASTER_API_KEY"));

$insertData = array(
    "Entity1" => array(
        "visited-pages" => array(
            "date" => "{% convert_date 'YYYY-MM-DDT10:35:23Z' '-1d' %}",
            "value" => "/online-demo"
        )
    )
);

print_r($slicingdice->insert($insertData));
?>
using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var slicingdice = new SlicingDice(masterKey: "MASTER_API_KEY");

            var insertData = new Dictionary<string, dynamic>{
                {"Entity1", new Dictionary<string, dynamic>{
                    {"visited-pages", new Dictionary<string, dynamic>{
                        {"date", "{% convert_date 'YYYY-MM-DDT10:35:23Z' '-1d' %}"},
                        {"value", "/online-demo"}
                    }}
                }}
            };

            var result = slicingdice.Insert(insertData);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}
package main
import (
    "fmt"
    "github.com/SlicingDice/slicingdice-go/slicingdice"
)
func main() {
    keys := new(slicingdice.APIKey)
    keys.MasterKey = "MASTER_API_KEY"
    slicingdice := slicingdice.New(keys, 60)

    insertData := map[string]interface{}{
        "Entity1": map[string]interface{}{
            "visited-pages": map[string]interface{}{
                "date": "{% convert_date 'YYYY-MM-DDT10:35:23Z' '-1d' %}",
                "value": "/online-demo",
            },
        },
    }

    fmt.Println(slicingdice.Insert(insertData))
}

Integer

You should use the integer column to store integer numbers, without any decimal places, such as 3, 10, -1 or 123642. It can be used to store data such as: age, number of children, number of visitors, and so on. It is possible to store a single value or multiple values in the same column for an entity.

Integer columns can store values from -9,223,372,036,854,775,808 (-263) to 9,223,372,036,854,775,807 (263 - 1).

Column limitations and restrictions

Below are the current limitations and restrictions for the integer columns.

  • Integer values must be in the interval from -9,223,372,036,854,775,808(-263) to 9,223,372,036,854,775,807 (263 - 1).
  • Integer values cannot have decimal places.
  • Cannot insert empty values, such as "".

Inserting data on an integer column

Column configured do store the latest-value

Below you can find a data insertion example of one value to one entity (Entity1) on a integer column (age), with storage parameter configured as latest-value.

Entities
Age

Entity1

32

INSERT INTO default ([entity-id], age) VALUES ("Entity1", 32);
$ curl -X POST https://api.slicingdice.com/v1/sql \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/sql' \
    -d 'INSERT INTO default ([entity-id], age) VALUES ("Entity1", 32);'
$ curl -X POST https://api.slicingdice.com/v1/insert \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
        "Entity1": {
            "age": 32
        }
    }'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY')

insert_data = {
    "Entity1": {
        "age": 32
    }
}

print(slicingdice.insert(insert_data))

import com.slicingdice.jslicer.SlicingDice;
import java.io.IOException;
import org.json.JSONObject;
import org.json.JSONArray;

public class Example {
    public static void main(String[] args) throws IOException {
        SlicingDice slicingdice = new SlicingDice("MASTER_API_KEY");

        JSONObject insertData = new JSONObject()
        .put("Entity1", new JSONObject()
            .put("age", 32));

        JSONObject result = slicingdice.insert(insertData);
        System.out.println(result.toString());
    }
}
require 'rbslicer'
slicingdice = SlicingDice.new(master_key: 'MASTER_API_KEY')

insert_data = {
    "Entity1" => {
        "age" => 32
    }
}

puts slicingdice.insert(insert_data)

const SlicingDice = require('slicerjs');

const slicingdice = new SlicingDice({masterKey: 'MASTER_API_KEY'});

const insertData = {
    "Entity1": {
        "age": 32
    }
};

slicingdice.insert(insertData).then((resp) => {
    console.log(resp);
}, (err) => {
    console.error(err);
});

<?php
use Slicer\SlicingDice;
$slicingdice = new SlicingDice(array("masterKey" => "MASTER_API_KEY"));

$insertData = array(
    "Entity1" => array(
        "age" => 32
    )
);

print_r($slicingdice->insert($insertData));
?>
using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var slicingdice = new SlicingDice(masterKey: "MASTER_API_KEY");

            var insertData = new Dictionary<string, dynamic>{
                {"Entity1", new Dictionary<string, dynamic>{
                    {"age", 32}
                }}
            };

            var result = slicingdice.Insert(insertData);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}
package main
import (
    "fmt"
    "github.com/SlicingDice/slicingdice-go/slicingdice"
)
func main() {
    keys := new(slicingdice.APIKey)
    keys.MasterKey = "MASTER_API_KEY"
    slicingdice := slicingdice.New(keys, 60)

    insertData := map[string]interface{}{
        "Entity1": map[string]interface{}{
            "age": 32,
        },
    }

    fmt.Println(slicingdice.Insert(insertData))
}

Column configured to store a list-of-values

Below you can find a data insertion example of multiple values to one entity (Entity1) on an integer column (list-of-ids), with storage parameter configured as list-of-values.

Entities
list-of-ids

Entity1

13430
24534
35643

INSERT INTO default ([entity-id], [list-of-ids]) VALUES ("Entity1", '[13430, 24534, 35643]');
$ curl -X POST https://api.slicingdice.com/v1/sql \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/sql' \
    -d 'INSERT INTO default ([entity-id], [list-of-ids]) VALUES ("Entity1", '[13430, 24534, 35643]');'
$ curl -X POST https://api.slicingdice.com/v1/insert \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
        "Entity1": {
            "list-of-ids": [ 
            13430, 
            24534, 
            35643
            ]
        }
    }'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY')

insert_data = {
    "Entity1": {
        "list-of-ids": [
            13430, 
            24534, 
            35643
        ]
    }
}

print(slicingdice.insert(insert_data))

import com.slicingdice.jslicer.SlicingDice;
import java.io.IOException;
import org.json.JSONObject;
import org.json.JSONArray;

public class Example {
    public static void main(String[] args) throws IOException {
        SlicingDice slicingdice = new SlicingDice("MASTER_API_KEY");

        JSONObject insertData = new JSONObject()
        .put("Entity1", new JSONObject()
            .put("list-of-ids", new JSONArray()
                .put(13430)
                .put(24534)
                .put(35643)));

        JSONObject result = slicingdice.insert(insertData);
        System.out.println(result.toString());
    }
}
require 'rbslicer'
slicingdice = SlicingDice.new(master_key: 'MASTER_API_KEY')

insert_data = {
    "Entity1" => {
        "list-of-ids" => [
            13430, 
            24534, 
            35643
        ]
    }
}

puts slicingdice.insert(insert_data)

const SlicingDice = require('slicerjs');

const slicingdice = new SlicingDice({masterKey: 'MASTER_API_KEY'});

const insertData = {
    "Entity1": {
        "list-of-ids": [
            13430, 
            24534, 
            35643
        ]
    }
};

slicingdice.insert(insertData).then((resp) => {
    console.log(resp);
}, (err) => {
    console.error(err);
});

<?php
use Slicer\SlicingDice;
$slicingdice = new SlicingDice(array("masterKey" => "MASTER_API_KEY"));

$insertData = array(
    "Entity1" => array(
        "list-of-ids" => array(
            13430, 
            24534, 
            35643
        )
    )
);

print_r($slicingdice->insert($insertData));
?>
using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var slicingdice = new SlicingDice(masterKey: "MASTER_API_KEY");

            var insertData = new Dictionary<string, dynamic>{
                {"Entity1", new Dictionary<string, dynamic>{
                    {"list-of-ids", new List<dynamic>{
                        13430, 
                        24534, 
                        35643
                    }}
                }}
            };

            var result = slicingdice.Insert(insertData);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}
package main
import (
    "fmt"
    "github.com/SlicingDice/slicingdice-go/slicingdice"
)
func main() {
    keys := new(slicingdice.APIKey)
    keys.MasterKey = "MASTER_API_KEY"
    slicingdice := slicingdice.New(keys, 60)

    insertData := map[string]interface{}{
        "Entity1": map[string]interface{}{
            "list-of-ids": []interface{}{
                13430,
                24534,
                35643,
            },
        },
    }

    fmt.Println(slicingdice.Insert(insertData))
}

Integer Event

You should use the integer-event column to store integer values that are associated with a date/time. Differently from integer attribute column, integer-event columns have different values throughout the time and tracking these changes is important. On the other hand, if your value is always constant or needs to be updated to keep the latest value, prefer using the integer attribute column.

Examples of integer-event usage include: total purchase amount, tracking number of users at your store every 10 minutes, number of game plays per minute for every player, number of produced fruits per farm every day and so on.

The date component must follow the ISO 8601 format: YYYY-MM-DDThh:mm:ssTZ. Example: {% convert_date 'YYYY-MM-DDT10:35:23Z' '-1d' %}.
You can also use a date with milliseconds values, but they will be automatically discarded. Example: 2017-06-01T10:35:23.954Z.
You are able to configure a timezone by replacing Z by +HH:MM or -HH:MM. Example: {% convert_date 'YYYY-MM-DDT10:35:23+03:00' '-1d' %} or {% convert_date 'YYYY-MM-DDT10:35:23-07:00' '-1d' %}.
Using Z is a shortcut to using UTC, such as in {% convert_date 'YYYY-MM-DDT10:35:23Z' '-1d' %}. However, it is important to know that the database will always store and fetch data in UTC format.

You may omit the date parameter when inserting data, but the database will use the current UTC timestamp. On the other hand, defining date gives you more control on the date being stored.

Column limitations and restrictions

Below are the current limitations and restrictions for the integer-event columns.

  • Integer event values must be in the interval from -9,223,372,036,854,775,808 (-263) to 9,223,372,036,854,775,807 (263 - 1).
  • Integer event values cannot have decimal places.
  • Integer event date cannot be older than 1990-01-01.

Inserting data on an integer event column

Below you can find a data insertion example of one value to one entity (Entity1) on a integer-event column (user-height).

Entities
User-height

Entity1

174 - {% convert_date 'YYYY-MM-DDT10:35:23Z' '-1d' %}

INSERT INTO default ([entity-id], [purchase-amount.0.value], [purchase-amount.0.date]) VALUES ("Entity1", 174, "{% convert_date 'YYYY-MM-DDT10:35:23Z' '-1d' %}");
$ curl -X POST https://api.slicingdice.com/v1/sql \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/sql' \
    -d 'INSERT INTO default ([entity-id], [purchase-amount.0.value], [purchase-amount.0.date]) VALUES ("Entity1", 174, "{% convert_date 'YYYY-MM-DDT10:35:23Z' '-1d' %}");'
$ curl -X POST https://api.slicingdice.com/v1/insert \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
        "Entity1": {
            "user-height": {
                "value": 174,
                "date": "{% convert_date 'YYYY-MM-DDT10:35:23Z' '-1d' %}"
            }
        }
    }'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY')

insert_data = {
    "Entity1": {
        "user-height": {
            "date": "{% convert_date 'YYYY-MM-DDT10:35:23Z' '-1d' %}",
            "value": 174
        }
    }
}

print(slicingdice.insert(insert_data))

import com.slicingdice.jslicer.SlicingDice;
import java.io.IOException;
import org.json.JSONObject;
import org.json.JSONArray;

public class Example {
    public static void main(String[] args) throws IOException {
        SlicingDice slicingdice = new SlicingDice("MASTER_API_KEY");

        JSONObject insertData = new JSONObject()
        .put("Entity1", new JSONObject()
            .put("user-height", new JSONObject()
                .put("date", "{% convert_date 'YYYY-MM-DDT10:35:23Z' '-1d' %}")
                .put("value", 174)));

        JSONObject result = slicingdice.insert(insertData);
        System.out.println(result.toString());
    }
}
require 'rbslicer'
slicingdice = SlicingDice.new(master_key: 'MASTER_API_KEY')

insert_data = {
    "Entity1" => {
        "user-height" => {
            "date" => "{% convert_date 'YYYY-MM-DDT10:35:23Z' '-1d' %}",
            "value" => 174
        }
    }
}

puts slicingdice.insert(insert_data)

const SlicingDice = require('slicerjs');

const slicingdice = new SlicingDice({masterKey: 'MASTER_API_KEY'});

const insertData = {
    "Entity1": {
        "user-height": {
            "date": "{% convert_date 'YYYY-MM-DDT10:35:23Z' '-1d' %}",
            "value": 174
        }
    }
};

slicingdice.insert(insertData).then((resp) => {
    console.log(resp);
}, (err) => {
    console.error(err);
});

<?php
use Slicer\SlicingDice;
$slicingdice = new SlicingDice(array("masterKey" => "MASTER_API_KEY"));

$insertData = array(
    "Entity1" => array(
        "user-height" => array(
            "date" => "{% convert_date 'YYYY-MM-DDT10:35:23Z' '-1d' %}",
            "value" => 174
        )
    )
);

print_r($slicingdice->insert($insertData));
?>
using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var slicingdice = new SlicingDice(masterKey: "MASTER_API_KEY");

            var insertData = new Dictionary<string, dynamic>{
                {"Entity1", new Dictionary<string, dynamic>{
                    {"user-height", new Dictionary<string, dynamic>{
                        {"date", "{% convert_date 'YYYY-MM-DDT10:35:23Z' '-1d' %}"},
                        {"value", 174}
                    }}
                }}
            };

            var result = slicingdice.Insert(insertData);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}
package main
import (
    "fmt"
    "github.com/SlicingDice/slicingdice-go/slicingdice"
)
func main() {
    keys := new(slicingdice.APIKey)
    keys.MasterKey = "MASTER_API_KEY"
    slicingdice := slicingdice.New(keys, 60)

    insertData := map[string]interface{}{
        "Entity1": map[string]interface{}{
            "user-height": map[string]interface{}{
                "date": "{% convert_date 'YYYY-MM-DDT10:35:23Z' '-1d' %}",
                "value": 174,
            },
        },
    }

    fmt.Println(slicingdice.Insert(insertData))
}

Decimal

You should use the decimal column to store decimal numbers with fixed precision, such as 1.01, -10.457 or 40154.4875. Use decimal columns for situations where decimal places are truly required: price, piece weight, sensor reading, optimal temperature, water flow. It is possible to store a single value or multiple values in the same column for an entity.

When creating a decimal column, you must define how many decimal-places will be used. For example, the value 7.03 requires 2 decimal places, whereas 1.48521 needs 5. This value must be defined with caution, given that it reduces the range of values a decimal column can store.

Since decimal columns have fixed precision representation, the minimum and maximum values depend on the defined number of decimal places. For example, with 2 decimal places, the minimum value is -92,233,720,368,547,758.08 (-263/102) and the maximum is 92,233,720,368,547,758.07 ((263 - 1)/102), whereas a decimal column with 15 decimal places can only store from -9,223.372036854775808 (-263/1015) to 9,223.372036854775807 ((263 - 1)/1015). Take this into account when deciding the number of decimal places.

Column limitations and restrictions

Below are the current limitations and restrictions for the decimal columns.

  • Decimal values must be in the interval from (-263/10p) to ((263 - 1)/10p) given p decimal places.
  • Decimal values can have at most 20 decimal places.
  • Cannot insert empty values, such as ""

Inserting data on a decimal column

Column configured do store the latest-value

Below you can find a data insertion example of one value to one entity (Entity1) on a decimal column (current-weight), with storage parameter configured as latest-value.

Entities
Current-weight

Entity1

32

INSERT INTO default ([entity-id], weight) VALUES ("Entity1", 98.326);
$ curl -X POST https://api.slicingdice.com/v1/sql \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/sql' \
    -d 'INSERT INTO default ([entity-id], weight) VALUES ("Entity1", 98.326);'
$ curl -X POST https://api.slicingdice.com/v1/insert \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
        "Entity1": {
            "current-weight": 98.326
        }
    }'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY')

insert_data = {
    "Entity1": {
        "current-weight": 98.326
    }
}

print(slicingdice.insert(insert_data))

import com.slicingdice.jslicer.SlicingDice;
import java.io.IOException;
import org.json.JSONObject;
import org.json.JSONArray;

public class Example {
    public static void main(String[] args) throws IOException {
        SlicingDice slicingdice = new SlicingDice("MASTER_API_KEY");

        JSONObject insertData = new JSONObject()
        .put("Entity1", new JSONObject()
            .put("current-weight", 98.326));

        JSONObject result = slicingdice.insert(insertData);
        System.out.println(result.toString());
    }
}
require 'rbslicer'
slicingdice = SlicingDice.new(master_key: 'MASTER_API_KEY')

insert_data = {
    "Entity1" => {
        "current-weight" => 98.326
    }
}

puts slicingdice.insert(insert_data)

const SlicingDice = require('slicerjs');

const slicingdice = new SlicingDice({masterKey: 'MASTER_API_KEY'});

const insertData = {
    "Entity1": {
        "current-weight": 98.326
    }
};

slicingdice.insert(insertData).then((resp) => {
    console.log(resp);
}, (err) => {
    console.error(err);
});

<?php
use Slicer\SlicingDice;
$slicingdice = new SlicingDice(array("masterKey" => "MASTER_API_KEY"));

$insertData = array(
    "Entity1" => array(
        "current-weight" => 98.326
    )
);

print_r($slicingdice->insert($insertData));
?>
using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var slicingdice = new SlicingDice(masterKey: "MASTER_API_KEY");

            var insertData = new Dictionary<string, dynamic>{
                {"Entity1", new Dictionary<string, dynamic>{
                    {"current-weight", 98.326}
                }}
            };

            var result = slicingdice.Insert(insertData);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}
package main
import (
    "fmt"
    "github.com/SlicingDice/slicingdice-go/slicingdice"
)
func main() {
    keys := new(slicingdice.APIKey)
    keys.MasterKey = "MASTER_API_KEY"
    slicingdice := slicingdice.New(keys, 60)

    insertData := map[string]interface{}{
        "Entity1": map[string]interface{}{
            "current-weight": 98.326,
        },
    }

    fmt.Println(slicingdice.Insert(insertData))
}

Column configured to store a list-of-values

Below you can find a data insertion example of multiple values to one entity (Entity1) on a decimal column (historic-weights), with storage parameter configured as list-of-values.

Entities
historic-weights

Entity1

98.326
104.639
85.245

INSERT INTO default ([entity-id], [historic-weights]]) VALUES ("Entity1", '[98.326, 104.639, 85.245]');
$ curl -X POST https://api.slicingdice.com/v1/sql \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/sql' \
    -d 'INSERT INTO default ([entity-id], [historic-weights]]) VALUES ("Entity1", '[98.326, 104.639, 85.245]');'
$ curl -X POST https://api.slicingdice.com/v1/insert \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
        "Entity1": {
            "historic-weights": [ 
              98.326, 
              104.639, 
              85.245
            ]
        }
    }'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY')

insert_data = {
    "Entity1": {
        "historic-weights": [
            98.326, 
            104.639, 
            85.245
        ]
    }
}

print(slicingdice.insert(insert_data))

import com.slicingdice.jslicer.SlicingDice;
import java.io.IOException;
import org.json.JSONObject;
import org.json.JSONArray;

public class Example {
    public static void main(String[] args) throws IOException {
        SlicingDice slicingdice = new SlicingDice("MASTER_API_KEY");

        JSONObject insertData = new JSONObject()
        .put("Entity1", new JSONObject()
            .put("historic-weights", new JSONArray()
                .put(98.326)
                .put(104.639)
                .put(85.245)));

        JSONObject result = slicingdice.insert(insertData);
        System.out.println(result.toString());
    }
}
require 'rbslicer'
slicingdice = SlicingDice.new(master_key: 'MASTER_API_KEY')

insert_data = {
    "Entity1" => {
        "historic-weights" => [
            98.326, 
            104.639, 
            85.245
        ]
    }
}

puts slicingdice.insert(insert_data)

const SlicingDice = require('slicerjs');

const slicingdice = new SlicingDice({masterKey: 'MASTER_API_KEY'});

const insertData = {
    "Entity1": {
        "historic-weights": [
            98.326, 
            104.639, 
            85.245
        ]
    }
};

slicingdice.insert(insertData).then((resp) => {
    console.log(resp);
}, (err) => {
    console.error(err);
});

<?php
use Slicer\SlicingDice;
$slicingdice = new SlicingDice(array("masterKey" => "MASTER_API_KEY"));

$insertData = array(
    "Entity1" => array(
        "historic-weights" => array(
            98.326, 
            104.639, 
            85.245
        )
    )
);

print_r($slicingdice->insert($insertData));
?>
using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var slicingdice = new SlicingDice(masterKey: "MASTER_API_KEY");

            var insertData = new Dictionary<string, dynamic>{
                {"Entity1", new Dictionary<string, dynamic>{
                    {"historic-weights", new List<dynamic>{
                        98.326, 
                        104.639, 
                        85.245
                    }}
                }}
            };

            var result = slicingdice.Insert(insertData);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}
package main
import (
    "fmt"
    "github.com/SlicingDice/slicingdice-go/slicingdice"
)
func main() {
    keys := new(slicingdice.APIKey)
    keys.MasterKey = "MASTER_API_KEY"
    slicingdice := slicingdice.New(keys, 60)

    insertData := map[string]interface{}{
        "Entity1": map[string]interface{}{
            "historic-weights": []interface{}{
                98.326,
                104.639,
                85.245,
            },
        },
    }

    fmt.Println(slicingdice.Insert(insertData))
}

Decimal Event

You should use the decimal-event column to store decimal values that are associated with a date/time. Differently from decimal attribute columns, decimal-event columns have different values throughout the time and tracking these changes is important. On the other hand, if your value is always constant or needs to be updatable to keep the latest value, prefer using the decimal column.

For example, decimal event is perfect for: tracking stock prices, sensor's temperature, product price change over time and so on.

When creating a decimal-event column, you must define how many decimal-places will be used. For instance, the value 7.03 requires 2 decimal places, whereas 1.48521 needs 5. This value must be defined with caution, given that it reduces the range of values a decimal column can store.

Since decimal columns have fixed precision representation, the minimum and maximum values depend on the defined number of decimal places. For instance, with 2 decimal places, the minimum value is -92,233,720,368,547,758.08 (-263/102) and the maximum is 92,233,720,368,547,758.07 ((263 - 1)/102), whereas a decimal column with 15 decimal places can only store from -9,223.372036854775808 (-263/1015) to 9,223.372036854775807 ((263 - 1)/1015). Take this into account when deciding the number of decimal places.

The date component must follow the ISO 8601 format: YYYY-MM-DDThh:mm:ssTZ, e.g. {% convert_date 'YYYY-MM-DDT10:35:23Z' '-1d' %}, you can also use a date with milliseconds values, but they will be automatically discarded. Example: 2017-06-01T10:35:23.954Z. You are able to configure a timezone by replacing Z by +HH:MM or -HH:MM. Example: {% convert_date 'YYYY-MM-DDT10:35:23+03:00' '-1d' %} or {% convert_date 'YYYY-MM-DDT10:35:23-07:00' '-1d' %}. Using Z is a shortcut to using UTC, such as in {% convert_date 'YYYY-MM-DDT10:35:23Z' '-1d' %}. However, it is important to know that the database always stores and fetch data in UTC format.

You may omit the date parameter when inserting data, but the database will use the current UTC timestamp. On the other hand, defining date gives you more control on the date being stored.

Column limitations and restrictions

Below are the current limitations and restrictions for the decimal-event columns.

  • Decimal values must be in the interval from (-263/10p) to ((263 - 1)/10p) given p decimal places.
  • Decimal event values can have at most 20 decimal-places.
  • Decimal event date cannot be older than 1990-01-01.

Inserting data on a decimal event column

Below you can find a data insertion example of one value to one entity (Entity1) on a decimal-event column (user-weight).

Entities
User-weight

Entity1

98.264 - {% convert_date 'YYYY-MM-DDT10:35:23Z' '-1d' %}

INSERT INTO default ([entity-id], [user-weight.0.value], [user-weight.0.date]) VALUES ("Entity1", 98.264, "{% convert_date 'YYYY-MM-DDT10:35:23Z' '-1d' %}");
$ curl -X POST https://api.slicingdice.com/v1/sql \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/sql' \
    -d 'INSERT INTO default ([entity-id], [user-weight.0.value], [user-weight.0.date]) VALUES ("Entity1", 98.264, "{% convert_date 'YYYY-MM-DDT10:35:23Z' '-1d' %}");'
$ curl -X POST https://api.slicingdice.com/v1/insert \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
        "Entity1": {
            "user-weight": {
                "value": 98.264,
                "date": "{% convert_date 'YYYY-MM-DDT10:35:23Z' '-1d' %}"
            }
        }
    }'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY')

insert_data = {
    "Entity1": {
        "user-weight": {
            "date": "{% convert_date 'YYYY-MM-DDT10:35:23Z' '-1d' %}",
            "value": 98.264
        }
    }
}

print(slicingdice.insert(insert_data))

import com.slicingdice.jslicer.SlicingDice;
import java.io.IOException;
import org.json.JSONObject;
import org.json.JSONArray;

public class Example {
    public static void main(String[] args) throws IOException {
        SlicingDice slicingdice = new SlicingDice("MASTER_API_KEY");

        JSONObject insertData = new JSONObject()
        .put("Entity1", new JSONObject()
            .put("user-weight", new JSONObject()
                .put("date", "{% convert_date 'YYYY-MM-DDT10:35:23Z' '-1d' %}")
                .put("value", 98.264)));

        JSONObject result = slicingdice.insert(insertData);
        System.out.println(result.toString());
    }
}
require 'rbslicer'
slicingdice = SlicingDice.new(master_key: 'MASTER_API_KEY')

insert_data = {
    "Entity1" => {
        "user-weight" => {
            "date" => "{% convert_date 'YYYY-MM-DDT10:35:23Z' '-1d' %}",
            "value" => 98.264
        }
    }
}

puts slicingdice.insert(insert_data)

const SlicingDice = require('slicerjs');

const slicingdice = new SlicingDice({masterKey: 'MASTER_API_KEY'});

const insertData = {
    "Entity1": {
        "user-weight": {
            "date": "{% convert_date 'YYYY-MM-DDT10:35:23Z' '-1d' %}",
            "value": 98.264
        }
    }
};

slicingdice.insert(insertData).then((resp) => {
    console.log(resp);
}, (err) => {
    console.error(err);
});

<?php
use Slicer\SlicingDice;
$slicingdice = new SlicingDice(array("masterKey" => "MASTER_API_KEY"));

$insertData = array(
    "Entity1" => array(
        "user-weight" => array(
            "date" => "{% convert_date 'YYYY-MM-DDT10:35:23Z' '-1d' %}",
            "value" => 98.264
        )
    )
);

print_r($slicingdice->insert($insertData));
?>
using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var slicingdice = new SlicingDice(masterKey: "MASTER_API_KEY");

            var insertData = new Dictionary<string, dynamic>{
                {"Entity1", new Dictionary<string, dynamic>{
                    {"user-weight", new Dictionary<string, dynamic>{
                        {"date", "{% convert_date 'YYYY-MM-DDT10:35:23Z' '-1d' %}"},
                        {"value", 98.264}
                    }}
                }}
            };

            var result = slicingdice.Insert(insertData);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}
package main
import (
    "fmt"
    "github.com/SlicingDice/slicingdice-go/slicingdice"
)
func main() {
    keys := new(slicingdice.APIKey)
    keys.MasterKey = "MASTER_API_KEY"
    slicingdice := slicingdice.New(keys, 60)

    insertData := map[string]interface{}{
        "Entity1": map[string]interface{}{
            "user-weight": map[string]interface{}{
                "date": "{% convert_date 'YYYY-MM-DDT10:35:23Z' '-1d' %}",
                "value": 98.264,
            },
        },
    }

    fmt.Println(slicingdice.Insert(insertData))
}

Boolean

You should use the boolean column to store logic values, such as true or false. Boolean is good when you are interested in whether the entity has a determined property or not.

You can use boolean for cases like: user's status (active or inactive), user's age confirmation (less than 18 years old), active or inactive sensor and so on.

Column limitations and restrictions

There are no limitations nor restrictions for the boolean columns.

Inserting data on a boolean column

Below you can find a data insertion example of a true boolean value to one entity (Entity1) on a boolean column (account-is-active).

Entities
Account-is-active

Entity1

true

INSERT INTO default ([entity-id], [account-is-active]) VALUES ("Entity1", true);
$ curl -X POST https://api.slicingdice.com/v1/sql \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/sql' \
    -d 'INSERT INTO default ([entity-id], [account-is-active]) VALUES ("Entity1", true);'
$ curl -X POST https://api.slicingdice.com/v1/insert \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
        "Entity1": {
            "account-is-active": true
        }
    }'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY')

insert_data = {
    "Entity1": {
        "account-is-active": True
    }
}

print(slicingdice.insert(insert_data))

import com.slicingdice.jslicer.SlicingDice;
import java.io.IOException;
import org.json.JSONObject;
import org.json.JSONArray;

public class Example {
    public static void main(String[] args) throws IOException {
        SlicingDice slicingdice = new SlicingDice("MASTER_API_KEY");

        JSONObject insertData = new JSONObject()
        .put("Entity1", new JSONObject()
            .put("account-is-active", true));

        JSONObject result = slicingdice.insert(insertData);
        System.out.println(result.toString());
    }
}
require 'rbslicer'
slicingdice = SlicingDice.new(master_key: 'MASTER_API_KEY')

insert_data = {
    "Entity1" => {
        "account-is-active" => true
    }
}

puts slicingdice.insert(insert_data)

const SlicingDice = require('slicerjs');

const slicingdice = new SlicingDice({masterKey: 'MASTER_API_KEY'});

const insertData = {
    "Entity1": {
        "account-is-active": true
    }
};

slicingdice.insert(insertData).then((resp) => {
    console.log(resp);
}, (err) => {
    console.error(err);
});

<?php
use Slicer\SlicingDice;
$slicingdice = new SlicingDice(array("masterKey" => "MASTER_API_KEY"));

$insertData = array(
    "Entity1" => array(
        "account-is-active" => true
    )
);

print_r($slicingdice->insert($insertData));
?>
using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var slicingdice = new SlicingDice(masterKey: "MASTER_API_KEY");

            var insertData = new Dictionary<string, dynamic>{
                {"Entity1", new Dictionary<string, dynamic>{
                    {"account-is-active", true}
                }}
            };

            var result = slicingdice.Insert(insertData);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}
package main
import (
    "fmt"
    "github.com/SlicingDice/slicingdice-go/slicingdice"
)
func main() {
    keys := new(slicingdice.APIKey)
    keys.MasterKey = "MASTER_API_KEY"
    slicingdice := slicingdice.New(keys, 60)

    insertData := map[string]interface{}{
        "Entity1": map[string]interface{}{
            "account-is-active": true,
        },
    }

    fmt.Println(slicingdice.Insert(insertData))
}

Date

You should use the date column to store date values, without time information. Differently from event column's data - where both value and date are required to retrieve the complete information - a date column has complete meaning by itself. It is possible to store a single value or multiple values in the same column for an entity.

Use date columns for things such as birthdate, sign up date, tests starting date, product launch date and so on.

The date must follow the ISO 8601 format: YYYY-MM-DD.

Column limitations and restrictions

Below are the current limitations and restrictions for the date columns.

  • Date values must be in ISO 8601 format: YYYY-MM-DD.

Inserting data on a date column

Column configured do store the latest-value

Below you can find a data insertion example of one value to one entity (Entity1) on a date column (user-birthdate), with storage parameter configured as latest-value.

Entities
User-birthdate

Entity1

1987-03-07

INSERT INTO default ([entity-id], [user-birthdate]) VALUES ("Entity1", "1987-03-07");
$ curl -X POST https://api.slicingdice.com/v1/sql \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/sql' \
    -d 'INSERT INTO default ([entity-id], [user-birthdate]) VALUES ("Entity1", "1987-03-07");'
$ curl -X POST https://api.slicingdice.com/v1/insert \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
        "Entity1": {
            "user-birthdate": "1987-03-07"
        }
    }'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY')

insert_data = {
    "Entity1": {
        "user-birthdate": "1987-03-07"
    }
}

print(slicingdice.insert(insert_data))

import com.slicingdice.jslicer.SlicingDice;
import java.io.IOException;
import org.json.JSONObject;
import org.json.JSONArray;

public class Example {
    public static void main(String[] args) throws IOException {
        SlicingDice slicingdice = new SlicingDice("MASTER_API_KEY");

        JSONObject insertData = new JSONObject()
        .put("Entity1", new JSONObject()
            .put("user-birthdate", "1987-03-07"));

        JSONObject result = slicingdice.insert(insertData);
        System.out.println(result.toString());
    }
}
require 'rbslicer'
slicingdice = SlicingDice.new(master_key: 'MASTER_API_KEY')

insert_data = {
    "Entity1" => {
        "user-birthdate" => "1987-03-07"
    }
}

puts slicingdice.insert(insert_data)

const SlicingDice = require('slicerjs');

const slicingdice = new SlicingDice({masterKey: 'MASTER_API_KEY'});

const insertData = {
    "Entity1": {
        "user-birthdate": "1987-03-07"
    }
};

slicingdice.insert(insertData).then((resp) => {
    console.log(resp);
}, (err) => {
    console.error(err);
});

<?php
use Slicer\SlicingDice;
$slicingdice = new SlicingDice(array("masterKey" => "MASTER_API_KEY"));

$insertData = array(
    "Entity1" => array(
        "user-birthdate" => "1987-03-07"
    )
);

print_r($slicingdice->insert($insertData));
?>
using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var slicingdice = new SlicingDice(masterKey: "MASTER_API_KEY");

            var insertData = new Dictionary<string, dynamic>{
                {"Entity1", new Dictionary<string, dynamic>{
                    {"user-birthdate", "1987-03-07"}
                }}
            };

            var result = slicingdice.Insert(insertData);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}
package main
import (
    "fmt"
    "github.com/SlicingDice/slicingdice-go/slicingdice"
)
func main() {
    keys := new(slicingdice.APIKey)
    keys.MasterKey = "MASTER_API_KEY"
    slicingdice := slicingdice.New(keys, 60)

    insertData := map[string]interface{}{
        "Entity1": map[string]interface{}{
            "user-birthdate": "1987-03-07",
        },
    }

    fmt.Println(slicingdice.Insert(insertData))
}

Column configured to store a list-of-values

Below you can find a data insertion example of multiple values to one entity (Entity1) on a date column (tests-dates), with storage parameter configured as list-of-values.

Entities
tests-dates

Entity1

2017-01-03
2017-02-07
2017-03-15
2017-04-01

INSERT INTO default ([entity-id], [tests-dates]]) VALUES ("Entity1", '["2017-01-03", "2017-02-07", "2017-03-15", "2017-04-01"]');
$ curl -X POST https://api.slicingdice.com/v1/sql \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/sql' \
    -d 'INSERT INTO default ([entity-id], [tests-dates]]) VALUES ("Entity1", '["2017-01-03", "2017-02-07", "2017-03-15", "2017-04-01"]');'
$ curl -X POST https://api.slicingdice.com/v1/insert \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
        "Entity1": {
        "tests-dates": [
            "2017-01-03",
            "2017-02-07",
            "2017-03-15",
            "2017-04-01"
            ]
        }
    }'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY')

insert_data = {
    "Entity1": {
        "tests-dates": [
            "2017-01-03", 
            "2017-02-07", 
            "2017-03-15", 
            "2017-04-01"
        ]
    }
}

print(slicingdice.insert(insert_data))

import com.slicingdice.jslicer.SlicingDice;
import java.io.IOException;
import org.json.JSONObject;
import org.json.JSONArray;

public class Example {
    public static void main(String[] args) throws IOException {
        SlicingDice slicingdice = new SlicingDice("MASTER_API_KEY");

        JSONObject insertData = new JSONObject()
        .put("Entity1", new JSONObject()
            .put("tests-dates", new JSONArray()
                .put("2017-01-03")
                .put("2017-02-07")
                .put("2017-03-15")
                .put("2017-04-01")));

        JSONObject result = slicingdice.insert(insertData);
        System.out.println(result.toString());
    }
}
require 'rbslicer'
slicingdice = SlicingDice.new(master_key: 'MASTER_API_KEY')

insert_data = {
    "Entity1" => {
        "tests-dates" => [
            "2017-01-03", 
            "2017-02-07", 
            "2017-03-15", 
            "2017-04-01"
        ]
    }
}

puts slicingdice.insert(insert_data)

const SlicingDice = require('slicerjs');

const slicingdice = new SlicingDice({masterKey: 'MASTER_API_KEY'});

const insertData = {
    "Entity1": {
        "tests-dates": [
            "2017-01-03", 
            "2017-02-07", 
            "2017-03-15", 
            "2017-04-01"
        ]
    }
};

slicingdice.insert(insertData).then((resp) => {
    console.log(resp);
}, (err) => {
    console.error(err);
});

<?php
use Slicer\SlicingDice;
$slicingdice = new SlicingDice(array("masterKey" => "MASTER_API_KEY"));

$insertData = array(
    "Entity1" => array(
        "tests-dates" => array(
            "2017-01-03", 
            "2017-02-07", 
            "2017-03-15", 
            "2017-04-01"
        )
    )
);

print_r($slicingdice->insert($insertData));
?>
using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var slicingdice = new SlicingDice(masterKey: "MASTER_API_KEY");

            var insertData = new Dictionary<string, dynamic>{
                {"Entity1", new Dictionary<string, dynamic>{
                    {"tests-dates", new List<dynamic>{
                        "2017-01-03", 
                        "2017-02-07", 
                        "2017-03-15", 
                        "2017-04-01"
                    }}
                }}
            };

            var result = slicingdice.Insert(insertData);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}
package main
import (
    "fmt"
    "github.com/SlicingDice/slicingdice-go/slicingdice"
)
func main() {
    keys := new(slicingdice.APIKey)
    keys.MasterKey = "MASTER_API_KEY"
    slicingdice := slicingdice.New(keys, 60)

    insertData := map[string]interface{}{
        "Entity1": map[string]interface{}{
            "tests-dates": []interface{}{
                "2017-01-03",
                "2017-02-07",
                "2017-03-15",
                "2017-04-01",
            },
        },
    }

    fmt.Println(slicingdice.Insert(insertData))
}

DateTime

You should use the datetime column to store date values, with time information. Differently from event column's data - where both value and date are required to retrieve the complete information - a datetime column has complete meaning by itself. It is possible to store a single value or multiple values in the same column for an entity.

Use datetime columns for things such as creation datetime, sign up datetime, tests starting datetime and so on.

Datetime must follow the ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.

Column limitations and restrictions

Below are the current limitations and restrictions for the datetime columns.

  • Datetime values must be in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.

Inserting data on a datetime column

Column configured do store the latest-value

Below you can find a data insertion example of one value to one entity (Entity1) on a datetime column (signup-time), with storage parameter configured as latest-value.

Entities
signup-time

Entity1

2018-05-30T15:22:50Z

INSERT INTO default ([entity-id], [signup-time]) VALUES ("Entity1", "2018-05-30T15:22:50Z");
$ curl -X POST https://api.slicingdice.com/v1/sql \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/sql' \
    -d 'INSERT INTO default ([entity-id], [signup-time]) VALUES ("Entity1", "2018-05-30T15:22:50Z");'
$ curl -X POST https://api.slicingdice.com/v1/insert \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
        "Entity1": {
            "signup-time": "2018-05-30T15:22:50Z"
        }
    }'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY')

insert_data = {
    "Entity1": {
        "signup-time": "2018-05-30T15:22:50Z"
    }
}

print(slicingdice.insert(insert_data))

import com.slicingdice.jslicer.SlicingDice;
import java.io.IOException;
import org.json.JSONObject;
import org.json.JSONArray;

public class Example {
    public static void main(String[] args) throws IOException {
        SlicingDice slicingdice = new SlicingDice("MASTER_API_KEY");

        JSONObject insertData = new JSONObject()
        .put("Entity1", new JSONObject()
            .put("signup-time", "2018-05-30T15:22:50Z"));

        JSONObject result = slicingdice.insert(insertData);
        System.out.println(result.toString());
    }
}
require 'rbslicer'
slicingdice = SlicingDice.new(master_key: 'MASTER_API_KEY')

insert_data = {
    "Entity1" => {
        "signup-time" => "2018-05-30T15:22:50Z"
    }
}

puts slicingdice.insert(insert_data)

const SlicingDice = require('slicerjs');

const slicingdice = new SlicingDice({masterKey: 'MASTER_API_KEY'});

const insertData = {
    "Entity1": {
        "signup-time": "2018-05-30T15:22:50Z"
    }
};

slicingdice.insert(insertData).then((resp) => {
    console.log(resp);
}, (err) => {
    console.error(err);
});

<?php
use Slicer\SlicingDice;
$slicingdice = new SlicingDice(array("masterKey" => "MASTER_API_KEY"));

$insertData = array(
    "Entity1" => array(
        "signup-time" => "2018-05-30T15:22:50Z"
    )
);

print_r($slicingdice->insert($insertData));
?>
using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var slicingdice = new SlicingDice(masterKey: "MASTER_API_KEY");

            var insertData = new Dictionary<string, dynamic>{
                {"Entity1", new Dictionary<string, dynamic>{
                    {"signup-time", "2018-05-30T15:22:50Z"}
                }}
            };

            var result = slicingdice.Insert(insertData);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}
package main
import (
    "fmt"
    "github.com/SlicingDice/slicingdice-go/slicingdice"
)
func main() {
    keys := new(slicingdice.APIKey)
    keys.MasterKey = "MASTER_API_KEY"
    slicingdice := slicingdice.New(keys, 60)

    insertData := map[string]interface{}{
        "Entity1": map[string]interface{}{
            "signup-time": "2018-05-30T15:22:50Z",
        },
    }

    fmt.Println(slicingdice.Insert(insertData))
}

Column configured to store a list-of-values

Below you can find a data insertion example of multiple values to one entity (Entity1) on a datetime column (login-times), with storage parameter configured as list-of-values.

Entities
login-times

Entity1

2018-05-30T15:22:50Z
2018-06-01T08:15:25Z
2018-06-06T10:00:00Z
2018-07-21T19:25:15Z

INSERT INTO default ([entity-id], [login-times]]) VALUES ("Entity1", '["2018-05-30T15:22:50Z","2018-06-01T08:15:25Z","2018-06-06T10:00:00Z","2018-07-21T19:25:15Z"]');
$ curl -X POST https://api.slicingdice.com/v1/sql \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/sql' \
    -d 'INSERT INTO default ([entity-id], [login-times]]) VALUES ("Entity1", '["2017-01-03", "2017-02-07", "2017-03-15", "2017-04-01"]');'
$ curl -X POST https://api.slicingdice.com/v1/insert \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
        "Entity1": {
        "login-times": [
            "2018-05-30T15:22:50Z",
            "2018-06-01T08:15:25Z",
            "2018-06-06T10:00:00Z",
            "2018-07-21T19:25:15Z"
        ]
        }
    }'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY')

insert_data = {
    "Entity1": {
        "login-times": [
            "2018-05-30T15:22:50Z",
            "2018-06-01T08:15:25Z",
            "2018-06-06T10:00:00Z",
            "2018-07-21T19:25:15Z"
        ]
    }
}

print(slicingdice.insert(insert_data))

import com.slicingdice.jslicer.SlicingDice;
import java.io.IOException;
import org.json.JSONObject;
import org.json.JSONArray;

public class Example {
    public static void main(String[] args) throws IOException {
        SlicingDice slicingdice = new SlicingDice("MASTER_API_KEY");

        JSONObject insertData = new JSONObject()
        .put("Entity1", new JSONObject()
            .put("login-times", new JSONArray()
                .put("2018-05-30T15:22:50Z"),
                .put("2018-06-01T08:15:25Z"),
                .put("2018-06-06T10:00:00Z"),
                .put("2018-07-21T19:25:15Z")));

        JSONObject result = slicingdice.insert(insertData);
        System.out.println(result.toString());
    }
}
require 'rbslicer'
slicingdice = SlicingDice.new(master_key: 'MASTER_API_KEY')

insert_data = {
    "Entity1" => {
        "login-times" => [
            "2018-05-30T15:22:50Z",
            "2018-06-01T08:15:25Z",
            "2018-06-06T10:00:00Z",
            "2018-07-21T19:25:15Z"
        ]
    }
}

puts slicingdice.insert(insert_data)

const SlicingDice = require('slicerjs');

const slicingdice = new SlicingDice({masterKey: 'MASTER_API_KEY'});

const insertData = {
    "Entity1": {
        "login-times": [
            "2018-05-30T15:22:50Z",
            "2018-06-01T08:15:25Z",
            "2018-06-06T10:00:00Z",
            "2018-07-21T19:25:15Z"
        ]
    }
};

slicingdice.insert(insertData).then((resp) => {
    console.log(resp);
}, (err) => {
    console.error(err);
});

<?php
use Slicer\SlicingDice;
$slicingdice = new SlicingDice(array("masterKey" => "MASTER_API_KEY"));

$insertData = array(
    "Entity1" => array(
        "login-times" => array(
            "2018-05-30T15:22:50Z",
            "2018-06-01T08:15:25Z",
            "2018-06-06T10:00:00Z",
            "2018-07-21T19:25:15Z"
        )
    )
);

print_r($slicingdice->insert($insertData));
?>
using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var slicingdice = new SlicingDice(masterKey: "MASTER_API_KEY");

            var insertData = new Dictionary<string, dynamic>{
                {"Entity1", new Dictionary<string, dynamic>{
                    {"login-times", new List<dynamic>{
                        "2018-05-30T15:22:50Z",
                        "2018-06-01T08:15:25Z",
                        "2018-06-06T10:00:00Z",
                        "2018-07-21T19:25:15Z"
                    }}
                }}
            };

            var result = slicingdice.Insert(insertData);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}
package main
import (
    "fmt"
    "github.com/SlicingDice/slicingdice-go/slicingdice"
)
func main() {
    keys := new(slicingdice.APIKey)
    keys.MasterKey = "MASTER_API_KEY"
    slicingdice := slicingdice.New(keys, 60)

    insertData := map[string]interface{}{
        "Entity1": map[string]interface{}{
            "login-times": []interface{}{
                "2018-05-30T15:22:50Z",
                "2018-06-01T08:15:25Z",
                "2018-06-06T10:00:00Z",
                "2018-07-21T19:25:15Z",
            },
        },
    }

    fmt.Println(slicingdice.Insert(insertData))
}

Unique ID

You should use the unique-id column to store text data that are exclusive to one entity and will never show up in multiple entities. Differently from string column, unique-id columns cannot store a list of values.

Unique ID is a perfect fit for cases which the nature of the data guarantees their uniqueness: Social Security Number, email address, username, HTTP cookie, vehicle license plate, sensor ID number, serial number and so on.

When you create a database, SlicingDice database automatically creates a unique-id data type column called Entity ID (API name: entity-id) for that database. This column will be transparently used by the database to store the value of all the entities you send to the API. It's not possible to delete this column nor change the API name (entity-id), although you can rename the column name.

Please note that SlicingDice does not provide uniqueness constraint, so it is up to the developer to guarantee the values being inserted are unique.

Column limitations and restrictions

Below are the current limitations and restrictions for the unique-id columns.

  • Unique ID values can have at most 1,000 characters.
  • Unique ID cannot store a list of values.

Inserting data on a unique id column

Below you can find a data insertion example of one value to one entity (Entity1) on a unique-id column (user-email).

Entities
user-email

Entity1

user1@slicingdice.com

INSERT INTO default ([entity-id], email) VALUES ("Entity1", "user1@slicingdice.com");
$ curl -X POST https://api.slicingdice.com/v1/sql \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/sql' \
    -d 'INSERT INTO default ([entity-id], email) VALUES ("Entity1", "user1@slicingdice.com");'
$ curl -X POST https://api.slicingdice.com/v1/insert \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
        "Entity1": {
            "user-email": "user1@slicingdice.com"
        }
    }'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY')

insert_data = {
    "Entity1": {
        "user-email": "user1@slicingdice.com"
    }
}

print(slicingdice.insert(insert_data))

import com.slicingdice.jslicer.SlicingDice;
import java.io.IOException;
import org.json.JSONObject;
import org.json.JSONArray;

public class Example {
    public static void main(String[] args) throws IOException {
        SlicingDice slicingdice = new SlicingDice("MASTER_API_KEY");

        JSONObject insertData = new JSONObject()
        .put("Entity1", new JSONObject()
            .put("user-email", "user1@slicingdice.com"));

        JSONObject result = slicingdice.insert(insertData);
        System.out.println(result.toString());
    }
}
require 'rbslicer'
slicingdice = SlicingDice.new(master_key: 'MASTER_API_KEY')

insert_data = {
    "Entity1" => {
        "user-email" => "user1@slicingdice.com"
    }
}

puts slicingdice.insert(insert_data)

const SlicingDice = require('slicerjs');

const slicingdice = new SlicingDice({masterKey: 'MASTER_API_KEY'});

const insertData = {
    "Entity1": {
        "user-email": "user1@slicingdice.com"
    }
};

slicingdice.insert(insertData).then((resp) => {
    console.log(resp);
}, (err) => {
    console.error(err);
});

<?php
use Slicer\SlicingDice;
$slicingdice = new SlicingDice(array("masterKey" => "MASTER_API_KEY"));

$insertData = array(
    "Entity1" => array(
        "user-email" => "user1@slicingdice.com"
    )
);

print_r($slicingdice->insert($insertData));
?>
using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var slicingdice = new SlicingDice(masterKey: "MASTER_API_KEY");

            var insertData = new Dictionary<string, dynamic>{
                {"Entity1", new Dictionary<string, dynamic>{
                    {"user-email", "user1@slicingdice.com"}
                }}
            };

            var result = slicingdice.Insert(insertData);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}
package main
import (
    "fmt"
    "github.com/SlicingDice/slicingdice-go/slicingdice"
)
func main() {
    keys := new(slicingdice.APIKey)
    keys.MasterKey = "MASTER_API_KEY"
    slicingdice := slicingdice.New(keys, 60)

    insertData := map[string]interface{}{
        "Entity1": map[string]interface{}{
            "user-email": "user1@slicingdice.com",
        },
    }

    fmt.Println(slicingdice.Insert(insertData))
}

Foreign Key

You should use the foreign-key column to store values, numeric or text, referring to other entities (rows) from a different dimension.

Please note that SlicingDice does not provide foreign key validation constraint, so it is up to the developer to guarantee the foreign key values being inserted correspond to the entity id from the other dimension.

Column limitations and restrictions

Below are the current limitations and restrictions for the foreign-key columns.

  • Unique ID values can have at most 1,000 characters.
  • Unique ID cannot store a list of values.