If I do

CREATE TABLE Sample (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  parent_id INTEGER,
  CONSTRAINT p FOREIGN KEY (parent_id) REFERENCES Sample (id)
);

I don't get any errors and the schema behaves as expected. But if I try

CREATE TABLE Aliases (
  alias_id INTEGER PRIMARY KEY AUTOINCREMENT,
  real_name TEXT NOT NULL,
  aka TEXT NOT NULL,
  CONSTRAINT xyz UNIQUE (real_name, aka),
  CONSTRAINT noCircularRef_A CHECK (
    real_name NOT IN (SELECT aka FROM Aliases)
  ),
  CONSTRAINT noCircularRef_B CHECK (
    aka NOT IN (SELECT real_name FROM Aliases)
  )
);

I am getting an `Error: no such table: Aliases` error. So how do I
implement this constraint? Are there any special keywords, like NEW and OLD
of trigger statements, to refer to current table?
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to