create table PERSONS (
  ID                            bigint generated by default as identity (start with 1000 increment by 40) not null,
  SURNAME                       varchar(64) not null,
  NAME                          varchar(64) not null,
  constraint pk_persons primary key (ID)
);

create table PHONES (
  id                            bigint generated by default as identity not null,
  phone_number                  varchar(7) not null,
  person_id                     bigint not null,
  constraint uq_phones_phone_number unique (phone_number),
  constraint pk_phones primary key (id)
);

-- foreign keys and indices
create index ix_phones_person_id on PHONES (person_id);
alter table PHONES add constraint fk_phones_person_id foreign key (person_id) references PERSONS (ID) on delete restrict on update restrict;

