Re: [sqlite] How to refer to `this` table?

2019-02-24 Thread Abroży Nieprzełoży
2019-02-23 10:03 GMT+01:00, Rocky Ji: > I went from > > https://sqlite.org/lang_createtable.html > > to > > https://sqlite.org/syntax/table-constraint.html > > to > > https://sqlite.org/syntax/expr.html > > and figured expr of `check` in table constraint may contain a nested select > after `not

Re: [sqlite] How to refer to `this` table?

2019-02-23 Thread Peter da Silva
As an aside, this schema seems to be violating https://www.kalzumeus.com/2010/06/17/falsehoods-programmers-believe-about-names/ particularly rule 21. ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org

Re: [sqlite] How to refer to `this` table?

2019-02-23 Thread Rocky Ji
I went from https://sqlite.org/lang_createtable.html to https://sqlite.org/syntax/table-constraint.html to https://sqlite.org/syntax/expr.html and figured expr of `check` in table constraint may contain a nested select after `not in`. On Sat, Feb 23, 2019, 1:24 PM Clemens Ladisch Rocky Ji

Re: [sqlite] How to refer to `this` table?

2019-02-22 Thread Amit Yaron
Try creating a trigger(https://sqlite.org/lang_createtrigger.html) instead of the constraint "noCircularRef_when the table already exists. On 23.2.2019 8:43, Rocky Ji wrote: If I do CREATE TABLE Sample ( id INTEGER PRIMARY KEY AUTOINCREMENT, parent_id INTEGER, CONSTRAINT p FOREIGN

Re: [sqlite] How to refer to `this` table?

2019-02-22 Thread Clemens Ladisch
Rocky Ji wrote: > 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

Re: [sqlite] How to refer to `this` table?

2019-02-22 Thread Simon Slavin
On 23 Feb 2019, at 6:43am, Rocky Ji wrote: > 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) >