Files
Baradb/docs/en/schema.md
T
dimgigov e1bae0c7a0 Add comprehensive documentation with i18n support (EN/BG)
- Add docs/ folder with English (en/) and Bulgarian (bg/) documentation
- Create index.md with language switching and links
- English docs: installation, quickstart, architecture, baraql, storage,
  schema, lsm, btree, vector, graph, fts, columnar, transactions,
  distributed, protocol, udf, api-binary, api-http, api-websocket
- Bulgarian docs: installation, quickstart, architecture, baraql,
  schema, lsm, btree, vector, graph, fts, transactions, distributed
- Update README license to BSD 3-Clause
- Add LICENSE file with BSD 3-Clause text
2026-05-06 16:51:14 +03:00

55 lines
1.0 KiB
Markdown

# Schema System
BaraDB uses a schema-first design with type inheritance and automatic migrations.
## Defining Types
```nim
import barabadb/schema/schema
var s = newSchema()
let person = newType("Person")
person.addProperty("name", "str", required = true)
person.addProperty("age", "int32")
s.addType("default", person)
```
## Type Inheritance
```nim
let employee = newType("Employee")
employee.setBases(@["Person"])
employee.addProperty("department", "str")
s.addType("default", employee)
# Resolve inheritance — Employee gets name, age, department
let resolved = s.resolveInheritance(employee)
```
## Schema Operations
### Diff
Compare two schemas:
```nim
let diff = s.diff(oldSchema, newSchema)
```
### Migrations
Schema changes are tracked and can generate migration scripts.
## Property Types
| Type | Description |
|------|-------------|
| `str` | String |
| `int32` | 32-bit integer |
| `int64` | 64-bit integer |
| `float32` | 32-bit float |
| `float64` | 64-bit float |
| `bool` | Boolean |
| `datetime` | Date/time value |
| `bytes` | Binary data |