
CREATE TABLE mytable (
    uname text PRIMARY KEY,
    CONSTRAINT uname_cons CHECK ((uname <> 'badname'::text))
);

COMMENT ON CONSTRAINT uname_cons ON mytable IS 'sanity check for uname';

CREATE TABLE bar (
    uname text NOT NULL,
    another_uname text NOT NULL,
    c circle
    CONSTRAINT bar_uname_check CHECK ((uname <> 'invalid'::text)),
    CONSTRAINT uname_check_not_null CHECK ((uname IS NOT NULL)),
    CONSTRAINT bar_pkey PRIMARY KEY (uname, another_uname),
    CONSTRAINT uname_uniq_cons UNIQUE (uname),
    CONSTRAINT bar_uname_fkey FOREIGN KEY (uname) REFERENCES mytable(uname),
    EXCLUDE USING gist (c WITH &&)
);

COMMENT ON CONSTRAINT bar_uname_check ON bar IS 'constraint for bar';
COMMENT ON CONSTRAINT uname_check_not_null ON bar IS 'not null comment';
COMMENT ON CONSTRAINT bar_pkey ON bar IS 'two column pkey comment';
COMMENT ON CONSTRAINT uname_uniq_cons ON bar IS 'unique constraint comment';
COMMENT ON CONSTRAINT bar_uname_fkey ON bar IS 'fkey comment';
COMMENT ON CONSTRAINT bar_c_excl ON bar IS 'exclusion constraint comment';

