Can't we make a non-primary key or non-unique key in a table as a foreign key in another table? I have got 4 tables named Blood_Bank,Consumer,Employee and Donor.Blood_Bank has SB as primary key which is a dummy attribute.I did not take bank_id as primary key since it can be repeated.To identify each repeated values,I have added one more column called SB.I took bank_id(neither primary nor unique)as the foreign key.These are my tables:

CREATE TABLE Blood_Bank(
    SB varchar(10) PRIMARY KEY,
    bank_id varchar(10) UNIQUE,
    bank_name char(25) NOT NULL,
    bank_add varchar(50) NOT NULL,
    bank_phone varchar(12) NOT NULL,
    b_id varchar(5) NOT NULL,
    b_grp varchar(5) NOT NULL,
    b_quantity varchar(4)NOT NULL,
    b_RHfactor varchar(5)NOT NULL);


CREATE TABLE Consumer(
    c_id varchar(20)PRIMARY KEY,
    c_name char(20) NOT NULL,
    c_add char(50) NOT NULL,
    c_blood varchar(10) NOT NULL,
    c_phone varchar(12) NOT NULL,
    bank_id varchar(10) REFERENCES Blood_Bank(bank_id));


CREATE TABLE Employee(
    emp_id int PRIMARY KEY,
    emp_name varchar(30) NOT NULL,
    emp_dept varchar(30) NOT NULL,
    emp_salary varchar(30) NOT NULL,
    emp_desgn varchar(40) NOT NULL,
    bank_id varchar(10) REFERENCES Blood_Bank(bank_id));

CREATE TABLE Donor(
    d_id varchar(20)PRIMARY KEY,
    d_name char(20)NOT NULL,
    d_blood varchar(15)NOT NULL,
    d_phone varchar(20) NOT NULL,
    d_gender char(20) NOT NULL,
    d_age varchar(15) NOT NULL,
    bank_id varchar(10) REFERENCES Blood_Bank(bank_id));


But,it is giving me the following error for the tables Consumer,Employee and Donor.


  ERROR:  there is no unique constraint matching given keys for referenced table "blood_bank".Please help.
First don't use varchar(x) in PostgreSQL, just use text. Second, all of your char(x) are likely wrong. In SQL, that means store whitespace padding. This is wasteful and a bad idea. You likely do not want char(x). Also, your id columns should probably be int (if you're designing this schema new).

You just need to drop your tables and try again. Your code works fine.