Frequently Asked Questions
Quick answers to fundamental questions about ThingsDB, stored state, relational modeling, modules, and deployment options.
What is ThingsDB and how does it differ from other programming languages?
ThingsDB is a distributed interpreter that functions as a programming language with integrated database capabilities. Unlike traditional interpreted languages such as Python, which lose variable states upon script termination, ThingsDB maintains state persistence. This means data and defined structures remain accessible and manipulable even after a query or script finishes execution. It's designed to offer a rich feature set including task scheduling, type definitions, procedures, and a pub/sub system, all while ensuring data is persistently stored in “things” (objects) within “collections” (similar to databases).
What are “things” and “properties” in ThingsDB, and how do they relate to data storage?
In ThingsDB, “things” are the fundamental objects where data is stored. Every collection has a “root” object, which is a regular “thing” and serves as the primary container for data within that collection. When you assign a value with a leading dot (e.g., .value = 'Remember me';), you are creating a “property” on the current collection's root “thing.” This makes the data persistent. In contrast, assigning a value without a dot (e.g., value = "I'm a variable";) creates a “variable” which only exists within the scope of a single query and is not persistent. Each stored “thing” also receives a unique ID.
How does ThingsDB handle different data types and immutability?
ThingsDB supports various fundamental data types, including integers, floats, booleans, strings, lists, tuples, things, and sets, as well as specialized types like errors, enumerators, and flags. Integers, strings, booleans, and floating-point values are all immutable, meaning their values cannot be changed once created. Operations on these types, such as string slicing, generate new values rather than modifying the original.
What is the significance of “scopes” in ThingsDB?
Scopes in ThingsDB define distinct environments for data storage and operations. Each “collection” (which can be compared to a database in SQL) has its own unique scope. For example, the default “stuff” collection has the full scope name /collection/stuff, which can be shortened to /c/stuff or //stuff. The @ symbol can also be used to represent a scope. ThingsDB allows for multiple collections to run on a single instance, each with its isolated scope, ensuring data separation and organization.
How does ThingsDB manage relations between data and what are common relation types?
ThingsDB provides mechanisms to establish and manage relations between different “typed things” (custom data types). Relations are crucial for modeling complex data structures:
- One-on-One (
T? <-> T?): One instance relates to one instance, with optional nillability. - Many-to-Many (
{T} <-> {T}): Multiple instances relate to multiple instances using sets. - One-to-Many (
T? <-> {T}): One instance relates to a set of instances, with optional nillability.
What are ThingsDB “modules” and how do they extend functionality?
ThingsDB “modules” are external components that significantly expand core capabilities. They can provide functionalities beyond standard database operations, such as sending emails, connecting to external databases, or making HTTP(S) requests. Modules can be Python-based or pre-built binary modules (often written in Go). They are installed within the /thingsdb scope using new_module(), typically via GitHub URLs. Once configured, modules expose methods callable directly from ThingsDB queries.
How does ThingsDB address query optimization and debugging?
ThingsDB offers built-in debugging and benchmarking tools. The log() function generates diagnostic messages to the node console and emits warning events to connected clients. For performance profiling, the timeit() function measures code block execution duration, helping developers benchmark query efficiency and optimize logic execution directly in the database runtime.
What deployment options and resources are available for ThingsDB?
- From Source: Build directly from C source code for maximum control and custom compilation.
- Docker & Kubernetes: Official container images for rapid, repeatable deployments with persistent volumes and k8s orchestration.
- Multi-Node Clusters: Boost read throughput and high availability by joining nodes into quorum-replicated clusters.
Have more questions or need architecture advice?
Our core engineering team and developer community are ready to assist you.