The Database
The database is the data the engine keeps: the records themselves, stored in order. In AltSql it’s one set of records from the sensor to the gateway, and both of the engine’s doors reach every one of them.
One Set of Records, From Sensor to Gateway
A device writes each reading or setting once, as a record with a sequence number and a checksum. The gateway receives those same records byte for byte and files each one under a key: for a reading, which device, what time and its sequence number. The payload stays exactly as the device wrote it. Nothing converts it on the way, so there’s no second copy to keep in step.
A reading stored as an AltSql record takes 26 bytes. The same reading as JSON takes 53.
One set of records: written once on the device, filed by key on the gateway, reached through both doors.
On the Device: A Log in Flash
The device keeps its records in its own flash, in a log built for chips that wear with every erase and can lose power in the middle of a write. It reads them back to decide on the spot, and it keeps working when the link drops. In one simulated run the power was cut 400,000 times, with nothing saved lost.
On the Gateway: The Whole Fleet in One File
The gateway keeps every device’s records in one file, sorted by key, so any record can be found without reading the rest. One device over a stretch of time is one sorted run of records. A batch from a device is saved in one transaction, a batch sent twice is applied once, and the gateway confirms it with one number. Two commit headers, written in order, mean a power cut leaves the file as it was before a change or after it.
In the Alpha, 100 simulated devices synced a million readings into one file at 279,094 readings a second, with 35.1 bytes of file per reading.
Both Doors, the Same Records
The gateway’s programs fetch what they can name by key, like a device’s latest reading or a command waiting for it. Engineers ask SQL questions of the same records, on the live data, with nothing exported first. Whatever goes in through one door is there for the other the moment it’s committed.
The live demo shows twelve devices syncing into one file in your browser. The engine page says how the two doors work, and AltSql DB has the gateway database in detail.