Relational Algebra, Predicate Logic, and Lojban

This book delves into relational algebra in detail, its connection to predicate logic and SQL, and how these fundamental database concepts can be expressed in the Lojban constructed language. Lojban is based on predicate logic, which makes it particularly suitable to act as an expressive, unambiguous substrate for querying and modeling relational data.

Table of Contents

  1. Relational Algebra Fundamentals
  2. Connection to Predicate Logic
  3. Relationship with SQL
  4. Relational Algebra in Lojban
  5. Common SQL Concepts: Sort By and Group By
  6. Case Studies and Practical Examples

Relational Algebra Fundamentals

Relational algebra is a procedural query language developed by Edgar F. Codd that serves as the theoretical foundation for relational databases. It operates on “relations” (conceptually tables) and produces new relations as a result.

The core operations in relational algebra include:


Connection to Predicate Logic

Predicate logic (first-order logic) is a formal system in which propositions are modeled via variables, predicates, and quantifiers ($\forall$, $\exists$).

Relational databases conceptually use the same model. A relation schema is fundamentally an $n$-ary predicate. For example, a relation schema Employee(ID, Name, Salary) matches the predicate $Employee(x, y, z)$.

Because Lojban’s grammar strictly implements first-order predicate logic, a direct translation from relational representations into Lojban sentences is natural.


Relationship with SQL

While relational algebra represents a mathematically robust procedural method for processing sets, SQL (Structured Query Language) is the commercial declarative language inspired by it.


Relational Algebra in Lojban

Lojban constructs its semantics around predicates (brivla). A standard brivla assigns a relationship between its positional arguments (sumti). Therefore, a database table is precisely an observation of a Lojban selbri across many different sets of arguments.

To discuss the structure of data querying itself (the algebra) in Lojban, we propose a new specialized lexicon of fu’ivla (loanwords or constructed words) and lujvo (compound words):

Core Lojban Terminology

Lojban Predicate Equivalence Example

Given table: zgana(observer, object, conditions) SQL:

SELECT observer FROM zgana WHERE object = "moon";

Lojban Relational Algebra equivalent: $ \pi_{observer}(\sigma_{object = \text{“moon”}}(zgana)) $ In Lojban grammar, this translates cleanly into an internal predicate query: ma zgana lo lunra (Who observes the moon?)


Common SQL Concepts: Sort By and Group By

While sorting and grouping are not strictly part of Codd’s original relational algebra (they belong to extended relational algebra for analytical databases), they are essential standard operations in SQL. Lojban needs precise ways to express these.

1. ORDER BY (Sort By)

Sorting transforms an unordered set of tuples into an ordered sequence or list based on a key attribute.

2. GROUP BY and Aggregation

Grouping partitions tuples into subsets sharing a common attribute value, allowing aggregation over those subsets.


Case Studies and Practical Examples

Let’s assume a schema modeling transactions in a store, using a Lojban selbri as our table structure. Table vecnu (seller, buyer, item, price).

Example 1: Basic Selection & Projection

Goal: Get all the items that Alice bought.

Example 2: JOIN Operations

We have the vecnu table, and another table kosta (item, cost_to_manufacturer). Goal: Combine tables to see sales next to manufacturing costs.

Example 3: GROUP BY & SUM

Goal: Get the total revenue for every seller.

Example 4: ORDER BY

Goal: List all sales ordered by price from highest to lowest.


Conclusions

Because Lojban was intentionally designed around the logical formulations that birthed relational database theory, bridging the gap between database query languages and spoken Lojban relies mostly on agreeing to procedural conventions. These proposed fu’ivla and lujvo (kricku, pilcuxna, joigro, girgau, porgau) grant us a robust framework to speak about data manipulation natively.