CREATE TABLE public."UserToken" (
id serial NOT NULL DEFAULT nextval('"UserToken_id_seq"'::regclass),
token varchar,
"userId" int4,
CONSTRAINT "UserToken_pkey" PRIMARY KEY (id)
);
CREATE TABLE public."User" (
id serial NOT NULL DEFAULT nextval('"User_id_seq"'::regclass),
email varchar NOT NULL,
password_hash varchar,
first_name varchar,
last_name varchar,
role varchar NOT NULL,
"language" varchar,
api_key varchar,
active bool NOT NULL,
confirmed timestamptz,
created timestamptz,
modified timestamptz,
CONSTRAINT "User_pkey" PRIMARY KEY (id)
);
So "userId" column created as regular int4, but there is no foreignKey. The use of foreign keys is the basic concept of relational databases, it's required for data integrity.
Code example:
Got DDLs:
So "userId" column created as regular int4, but there is no foreignKey. The use of foreign keys is the basic concept of relational databases, it's required for data integrity.