next up previous contents
Next: Table Constraints Up: The Ur/Web Standard Library Previous: HTTP   Contents


Everything about SQL database access is restricted to server-side code.

The fundamental unit of interest in the embedding of SQL is tables, described by a type family and creatable only via the $ \mathsf{table}$ declaration form.

\mathsf{con} \; \mathsf{sql\_table} :: \{\m...
...Type}\} \to \{\{\mathsf{Unit}\}\} \to \mathsf{Type}

The first argument to this constructor gives the names and types of a table's columns, and the second argument gives the set of valid keys. Keys are the only subsets of the columns that may be referenced as foreign keys. Each key has a name.

We also have the simpler type family of SQL views, which have no keys.

\mathsf{con} \; \mathsf{sql\_view} :: \{\mathsf{Type}\} \to \mathsf{Type}

A multi-parameter type class is used to allow tables and views to be used interchangeably, with a way of extracting the set of columns from each.

\mathsf{class} \; \mathsf{fieldsOf} :: \mat...
... (\mathsf{sql\_view} \; \mathsf{fs}) \; \mathsf{fs}