title: Setting up foreign key with different datatype
body: <p>If I create two tables and I want to set one column as foreign key to another table column <strong>why the hell am I allowed to set foreign key column datatype?</strong> </p>
  
  <p>It just doesn't make any sense or am I missing something? Is there any scenario where column with foreign keys has different datatype on purpose?</p>
  
  <p>Little more deeper about my concerns, I tried to use pgadmin to build some simple Postgres DB. I made first table with primary key <code>serial</code> datatype. Then I tried to make foreign key but what datatype? I have seen somewhere <code>serial</code> is <code>bigint unsigned</code>. But this option doesn't even exists in pgadmin. Of course I could use sql but then why am I using gui? So I tried Navicat instead, same problem. I feel like with every choice I do another mistake in my DB design... </p>
  
  <p><strong>EDIT:</strong> </p>
  
  <p>Perhaps I asked the question wrong way. 
  I was allowed to do build structure:</p>
  
  <pre><code>CREATE TABLE user
  (
    id bigint NOT NULL,
    CONSTRAINT user_pkey PRIMARY KEY (id)
  )
  WITH (
    OIDS=FALSE
  );
  
  CREATE TABLE book
  (
    user integer,
    CONSTRAINT dependent_user_fkey FOREIGN KEY (user)
        REFERENCES user (id) MATCH SIMPLE
        ON UPDATE NO ACTION ON DELETE NO ACTION
  )
  WITH (
    OIDS=FALSE
  );
  </code></pre>
  
  <p>I insert some data to table user:</p>
  
  <pre><code>INSERT INTO user(id)
      VALUES (5000000000);
  </code></pre>
  
  <p>But I can't cast following insert:</p>
  
  <pre><code>INSERT INTO book(user)
      VALUES (5000000000);
  </code></pre>
  
  <p>with <code>ERROR: integer out of range</code> which is understandable, but obvious design error.</p>
  
  <p><strong>And my question is</strong>: Why when we set <code>CONSTRAINT</code>, data types are not being validated. If I'm wrong, answer should contain scenario where it is useful to have different data types. </p>