Таблица Users:
CREATE TABLE survey_schema.Users
(
User_ID smallserial NOT NULL PRIMARY KEY,
Role_ID smallint NOT NULL,
FOREIGN KEY(Role_ID) REFERENCES survey_schema.Roles(Role_ID) ON UPDATE CASCADE ON DELETE CASCADE,
Name varchar(20) NOT NULL,
Surname varchar(20) NOT NULL,
Email varchar(30) NOT NULL,
Password char(64) NOT NULL
);
добавил проверку уникальности:
ALTER TABLE survey_schema.Users ADD CONSTRAINT email_unique_check UNIQUE(email);
проверки через функции:
CREATE EXTENSION citext;
CREATE DOMAIN email AS citext
CHECK ( value ~ '^[a-zA-Z0-9.!#$%&''*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$' );