How to use a foreign key? I'm creating the following table:

CREATE TABLE fund_identifier
(
    id BIGSERIAL PRIMARY KEY NOT NULL,
    identifier TEXT NOT NULL
);
CREATE UNIQUE INDEX IF NOT EXISTS fund_identifier_pkey ON fund_identifier (id);
CREATE UNIQUE INDEX IF NOT EXISTS fund_identifier_identifier_uindex ON fund_identifier (identifier)


However, I'm not sure what would be the best practice to use identifier as a foreign key. Should I use as reference the value of the foreign key like this:

    CREATE TABLE security_papers (
      id                                        BIGSERIAL,
      fund_identifier                           TEXT,
      as_of_date                                DATE,
          ...
      CONSTRAINT security_papers_fund_identifier_fk FOREIGN KEY (fund_identifier) REFERENCES fund_identifier (identifier)
    }


Or, should I use its id? Like this:

    CREATE TABLE security_papers (
      id                                        BIGSERIAL,
      fund_identifier_id                        BIGSERIAL,
      as_of_date                                DATE,
          ...
      CONSTRAINT security_papers_fund_identifier_fk FOREIGN KEY (fund_identifier) REFERENCES fund_identifier (identifier)
    }


My guess is on the second approach when it comes to the normalization rules. On the logical side, my application would need to look for  the id of fund_identifier first, before persisting anything at security_papers table. Right ? 

But if I go with the second approach, this would be delegated to the database. Making my application logic, easier to implement.

Please let me know your thoughts, and if I'm missing some concept here. Thank you!
However, I'm not sure what would be the best practice to use identifier as a foreign key. Should I use as reference the value of the foreign key like this


A couple of points before hand.


There is no need to mark a PRIMARY KEY NOT NULL, and DO NOT create a UNIQUE index on it. That'll just slow things down. It's already implemented with a ``UNIQUE` index.
Reconsider bigserial, do you really need it?
If you do not use id, but instead fund_id, or id_fund or the like, you can use the USING (fund_id) clause which is


easier to type
less error-prone

PostgreSQL provides for a shorter more terse syntax to refer to primary keys..

-- it'll guess primary key
fund_identifier  type  REFERENCES table;



That said, I think your questions is if your primary table uses bigserial how does your foreign table declare the column that refers to it.. Like this, using bigint

fund_identifier  bigint  REFERENCES table;


So your schema should look like

CREATE TABLE funds (
    id_fund    bigserial PRIMARY KEY,
    identifier text      UNIQUE NOT NULL
);

CREATE TABLE security_papers (
  id_security_paper    bigserial  NOT NULL
  id_fund              bigint     REFERENCES funds
  as_of_date           date,
);


Then

SELECT * FROM security_papers
JOIN funds
  USING (id_fund);