Skip to main content
In SLang, you define your data model using Entities (tables) and Relations (foreign keys/joins).

Entities

An entity represents a data object. It contains fields with specific types and constraints.
entity Patient
  description "Patient record."
  fields
    `Full Name`: TEXT
      description "The patient's legal name."
      minLength 1
    `Date Of Birth`: DATE
      description "DOB for age verification."
    MRN: TEXT
      description "Medical Record Number."
    Status: ENUM("active", "archived") := "active"

Field types

SLang supports high-level primitives that map to optimized database storage:
TypeDescription
TEXTStrings of text.
NUMBERIntegers or floating point numbers.
BOOLEANtrue or false.
DATECalendar date (YYYY-MM-DD).
DATE_TIMETimestamp.
EMAILValidated email string.
URLValidated web link.
CURRENCY_AMOUNTMonetary value.
ENUM("a", "b")Restricted set of strings.

Field constraints & metadata

Fields can be configured with nested properties:
  • description: Documentation for the field (visible in generated APIs/docs).
  • minLength: Enforces minimum character count for TEXT.
  • :=: Sets a default value.
  • ?: Marks the field as optional (nullable).

Relations

Relations define how entities connect. They are defined outside the entity block to keep definitions clean. The syntax is: relation Left[FieldOnLeft] Cardinality --- Cardinality Right[FieldOnRight]

One-to-many

A Clinic has many Patients; a Patient belongs to one Clinic.
relation Clinic[Patients] 1 --- 0..* Patient[Clinic]
  • Clinic.Patients will return a list of patients.
  • Patient.Clinic will return a single clinic.

Many-to-many

A User can belong to multiple Organizations, and an Organization has many Users. usually via a join entity (Membership).
entity Membership
  fields
    Role: ENUM("admin", "member")

relation User[Memberships] 1 --- 0..* Membership[Member]
relation Organization[Members] 1 --- 0..* Membership[Organization]