 ON UPDATE CASCADE
   NOT DEFERRABLE;
 
+ALTER TABLE public.rental ADD CONSTRAINT device_user_rental_fk
+FOREIGN KEY (returner)
+REFERENCES public.device_user (id)
+ON DELETE NO ACTION
+ON UPDATE CASCADE
+  DEFERRABLE INITIALLY DEFERRED;
+
 ALTER TABLE public.rental ADD CONSTRAINT device_rental_fk
 FOREIGN KEY (device_id)
 REFERENCES public.device (id)

  first_name VARCHAR(50) NOT NULL,
  last_name VARCHAR(50) NOT NULL,
  pin VARCHAR(10),
  CONSTRAINT device_user_pk PRIMARY KEY (id)
);



CREATE TABLE public.rental (
  id INTEGER NOT NULL DEFAULT nextval('public.rental_id_seq'),
  user_id INTEGER,
  device_id INTEGER NOT NULL,
  rental_time TIMESTAMP NOT NULL,
  return_time TIMESTAMP,
  is_returned BOOLEAN NOT NULL,
  returner INTEGER,
  CONSTRAINT rental_pk PRIMARY KEY (id)
);

