diff options
| author | Marcos Magueta <maguetamarcos@gmail.com> | 2026-03-07 02:40:26 -0300 |
|---|---|---|
| committer | Marcos Magueta <maguetamarcos@gmail.com> | 2026-03-07 02:40:26 -0300 |
| commit | e9bc4aa3fa0e775acf1978722da1fde1ed8a469d (patch) | |
| tree | ff78d21ba9a03acae20b15bb2fad2f27bcde75e1 /lib/schema.ml | |
| parent | fcd8571577f2b98ffc8fa2b95781ed16982804a9 (diff) | |
| download | Sakura-e9bc4aa3fa0e775acf1978722da1fde1ed8a469d.tar.gz Sakura-e9bc4aa3fa0e775acf1978722da1fde1ed8a469d.zip | |
erlang port commands and generated tests
Diffstat (limited to '')
| -rw-r--r-- | lib/schema.ml | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/schema.ml b/lib/schema.ml new file mode 100644 index 0000000..e17f7a5 --- /dev/null +++ b/lib/schema.ml @@ -0,0 +1,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 "," |
