What dialect of SQL do you target exactly?

In MySQL / SQL Server / Oracle / MS Access / PostGresQL / H2 you can write:


CREATE TABLE Germans(c0 VARCHAR(255) PRIMARY KEY, c1 VARCHAR(255));
ALTER TABLE Germans ADD CONSTRAINT CHK_GermansRefl CHECK (c0 = c1);

CREATE TABLE Italians(c0 VARCHAR(255) PRIMARY KEY, c1 VARCHAR(255));
ALTER TABLE Italians ADD CONSTRAINT CHK_ItaliansRefl CHECK (c0 = c1);

CREATE TABLE friendOf(c0 VARCHAR(255) PRIMARY KEY, c1 VARCHAR(255));
CREATE TABLE friendOf2(c0 VARCHAR(255) PRIMARY KEY, c1 VARCHAR(255));


This would cover the axioms:

\[
\begin{align}
\forall v_0, v_1.\; \textsf{Germans}(v_0,v_1) & \to v_0 = v_1 \\\\
\forall v_2, v_3.\; \textsf{Italians}(v_2,v_3) & \to v_2 = v_3
\end{align}
\]

You might want to have an optimization to elide all these duplicate columns. I suspect it can add significant overhead.

(As I look at your schema generation code, I am seeing that this is easier said than done.)

Moreover, it might be a good idea to introduce `NOT NULL` constraints everywhere to match the FOL semantics you propose.