This document describes the SCID5 storage model used by libscid-database.
A SCID5 database is a logical three-file unit:
.si5: index records.sg5: encoded game data.sn5: namebase and database metadataAll three files belong together. A database path should be understood as the base name of this triplet rather than as one physical file.
The .si5 file stores one fixed-size record per game. Each record is 56 bytes:
uint32_t wordsThe fixed record size allows an existing game's index entry to be overwritten in place.
Each record contains:
The .sn5 file stores strings with an associated name type. The current name types are:
Each entry is encoded as a varint followed by string bytes. The low three bits of the varint store the name type; the remaining bits store the string length.
The namebase is append-oriented. When a game is modified and uses a new name, that name is appended and the new ID is written into the corresponding index entry.
Database information such as type, description, autoload and flag labels is also stored in the namebase stream.
The .sg5 file stores encoded game blobs. A game blob contains:
Move data is compactly encoded. Normal moves use one byte where the high four bits identify the moving piece index. The king always has index 0, leaving low special values available for null moves, castling, NAGs, comments, variation start/end and end-of-game markers.
Trailing comment placeholders may be omitted when they are not needed.
The SCID5 codec currently encodes these practical limits:
Index records also impose field-specific limits, such as:
Game flags can mark games as deleted, but that does not necessarily remove data from the .sg5 file immediately. Compaction rewrites the database into a fresh database unit and removes unused or sparse data.
Applications that need to reclaim disk space should call the session compaction API rather than trying to edit the triplet directly.
SCID5 stores names and game data in a compact representation designed for fast database operations. It is not a PGN archive. PGN import/export is a separate concern from the native database representation.
Consumers should use scidBaseT and the public library APIs to manipulate SCID5 databases. Direct modification of .si5, .sg5 or .sn5 files requires full knowledge of the encoding and consistency rules.