title: postgresql: constaint to have unique values across 2 tables
body: <p>I have 2 tables:</p>
  <pre><code>CREATE TABLE public.&quot;user&quot;
  (
      id integer NOT NULL DEFAULT nextval('user_id_seq'::regclass),
      username character varying(256) COLLATE pg_catalog.&quot;default&quot;,
      CONSTRAINT user_pkey PRIMARY KEY (id)
  )
  
  CREATE TABLE public.user_tenant
  (
      user_id integer NOT NULL,
      tenant_id integer NOT NULL,
      CONSTRAINT user_fk FOREIGN KEY (user_id)
          REFERENCES public.&quot;user&quot; (id) MATCH SIMPLE
          ON UPDATE NO ACTION
          ON DELETE CASCADE
  )
  </code></pre>
  <p>I need to have unique values (user.username, user_tenant.tenant_id). How can I declare such a constraint?</p>