aboutsummaryrefslogtreecommitdiffstats
path: root/lib/schema.ml
blob: e17f7a50b687a97d8a04b59be31c4cc62fbc6a61 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
(** Schema: maps attribute names to domain/type names.

    A schema defines the structure of a relation by listing each attribute
    and its associated domain (type). This is used for:
    - Hashing relations (schema is part of the relation identity)
    - Validation (checking tuple membership)
    - Persistence (storing and loading relations with their structure) *)

type t = (string * string) list

let empty : t = []

let add name domain_name (schema : t) : t =
  (name, domain_name) :: schema

let attributes (schema : t) =
  List.map fst schema

let to_string schema =
  List.map (fun (n, t) -> n ^ ":" ^ t) schema
  |> String.concat ","