{"id":26824016,"url":"https://github.com/willmcpherson2/sdb","last_synced_at":"2025-03-30T09:17:37.776Z","repository":{"id":252761426,"uuid":"838764829","full_name":"willmcpherson2/sdb","owner":"willmcpherson2","description":"The Shadowbox Database","archived":false,"fork":false,"pushed_at":"2024-08-25T08:52:15.000Z","size":74,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-25T10:04:18.415Z","etag":null,"topics":["relational-algebra","relational-database","rust","sql"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/willmcpherson2.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-06T09:47:15.000Z","updated_at":"2024-08-25T08:52:17.000Z","dependencies_parsed_at":"2024-08-22T09:55:28.113Z","dependency_job_id":"4f8729c2-1798-4ba0-a289-4a052d0d4879","html_url":"https://github.com/willmcpherson2/sdb","commit_stats":null,"previous_names":["willmcpherson2/drd"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willmcpherson2%2Fsdb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willmcpherson2%2Fsdb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willmcpherson2%2Fsdb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willmcpherson2%2Fsdb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/willmcpherson2","download_url":"https://codeload.github.com/willmcpherson2/sdb/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246296576,"owners_count":20754635,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["relational-algebra","relational-database","rust","sql"],"created_at":"2025-03-30T09:17:37.278Z","updated_at":"2025-03-30T09:17:37.768Z","avatar_url":"https://github.com/willmcpherson2.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# The Shadowbox Database\n\nShadowbox (sdb) is a simple relational database. It implements the [relational algebra](https://en.wikipedia.org/wiki/Relational_algebra#Introduction).\n\nsdb has no `CREATE TABLE` or `INSERT` statements. Instead, it has table literals and **variable shadowing**.\n\n```\nStaff =\n  id, name, employed :\n  1, 'Alice', true,\n  2, 'Bob', true;\nStaff = Staff + id, name, employed : 3, 'Charlie', false;\nStaff\n```\n\nIn this example, we first define a `Staff` table. Then we re-define it as the union of the old table and a new table. Then we put `Staff` in the body of the let expression to query it.\n\n```\n$ sdb run examples/charlie.sdb\nid, name, employed : 1, 'Alice', true, 2, 'Bob', true, 3, 'Charlie', false\n```\n\nHowever, this is not persistent.\n\nTo persist our staff table, we first need to start the database server:\n\n```\n$ sdb start\nStarting server\nDirectory: db\nhttp://localhost:2345\n```\n\nNow we can set up our staff table:\n\n```\nStaff =\n  id, name, employed :\n  1, 'Alice', true,\n  2, 'Bob', true;\nStaff\n```\n\n```\n$ sdb run -s localhost:2345 examples/staff.sdb\nid, name, employed : 1, 'Alice', true, 2, 'Bob', true\n```\n\nIt will persist in human-readable form:\n\n```\n$ cat db/Staff \nid, name, employed : 1, 'Alice', true, 2, 'Bob', true\n```\n\nNow we can re-define `Staff` persistently:\n\n```\nStaff = Staff + id, name, employed : 3, 'Christian', true;\nStaff\n```\n\n```\n$ sdb run -s localhost:2345 examples/christian.sdb \nid, name, employed : 1, 'Alice', true, 2, 'Bob', true, 3, 'Christian', true\n```\n\nHow did that work? It's equivalent to our first example. When you define a variable, the server writes it to disk. When you reference a variable, the server reads it from disk. This means that variable shadowing works across connections.\n\n## Syntax\n\n```\nexp\n  var = exp; exp\n  vars \u003c- exp\n  exp ? exp\n  exp + exp\n  exp - exp\n  exp * exp\n  vars : exps\n  exp || exp\n  exp \u0026\u0026 exp\n  exp == exp\n  not exp\n  bool\n  int\n  str\n  var\n\nvars\n  var, vars\n  var\n  nil\n\nexps\n  exp, exps\n  exp\n  nil\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillmcpherson2%2Fsdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwillmcpherson2%2Fsdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillmcpherson2%2Fsdb/lists"}