# Relational Algebra in Tcl

Andrew Mangona presnted his work on TclRAL, a relational algebra extension for Tcl. It provides:

- relational values native to Tcl
- rigirous & complete set of relational operators
- useful set of integrity constraints
- explore relational concepts in Tcl programming
- no new (Tcl) syntax required

Tuple type, 3 part list. Tuples have a heading: attribute name, attribute type.

Relvars are mirrored as standard Tcl variables.
Relvars can have referential integrity constraints applied to their values.
The extention provides 38 relational operators. No time to cover them all
in his talk.

#### Examples of important operators

- Set operations
- union, intersection, difference, comparison
- Selection operators
- restrict, project, eliminate
- Join operations
- join [natural join], times [cartesian product], divide, semijoin, semiminus
- Computational operations
- summarize, extend, rank
- Linkage to other Tcl data types
- ordinary variables, arrays, dict, matrix

TclRAL enforces declarative referential integrity constraint:
Association Constraints, Partition Constraints and Correlation Constraints.

Any time a relvar is modified the constraints are evaluated. Either you
pass the constraints and can go forward; otherwise throw an error.

Association constraints define traditional (database-like?) referential
constraints. Attributes in one relation refers to attributes in another
relation. References are identifiers. Multiplicity and conditionality can
be specified.

Partition constraints define a set of relations that are completed and
disjoint sub-sets of some super-set relation.

Correlation constraints: Correlation constraints define an integrity
constraint between two relvars that is mediated by a 3rd. The correlating
relvar references the two other relvars in the constraint. Often arises in
a many-to-many situation.

Lots of screenshot examples, but with a notation that while I'm sure
is common to those who work with relational algebra, I did not understand
well enough to transcribe from the back of the room.

#### TclRAL is NOT:

- Not a DBMS
- Not SQL based
- No NULL's or three valued logic
- No transparent persistence (do provide lots of way to save off relvars and
constraints, including inside a Metakit db)

#### What's next:

- Relvar tracing
- Cascading update and delete
- Default values and system assigned identifiers
- Procedural constraints
- Transparent persistence
- Continuing improvements in the code base

—Michael A. Cleverly

Wednesday, October 11, 2006 at 14:31