ORA-02270: no matching unique or primary key for this column-list

Fullname etc. are not declared as unique in the parent table, and therefore you can't reference them from the child table.

Why do you need to duplicate these columns in the child table?

EDIT:

Locking at you child table you say that:

create table bit_2015_sep_cit4114_fyp_G_
( ...
, Full_Name VARCHAR2 (50) NOT NULL 
      REFERENCES STUDENTINFO(Full_Name)

What this means is that there must be a unique row in STUDENTINFO with this fullname. I.e. you need to declare that table:

CREATE TABLE STUDENTINFO
( ...
, Full_Name VARCHAR2 (50) NOT NULL
     UNIQUE,

I doubt that full_name is unique which means you cant declare a foreign key against this column.

You seem to assume that there will be performance problems later on and therefore you de-normalize your database. IMO this is a big mistake, start with a normalized database and de-normalize only when there is reason to do so.

If you insist on de-normalizing you can use a trick like:

CREATE TABLE STUDENTINFO
( Student_ID VARCHAR2 (10) PRIMARY KEY
, Full_Name VARCHAR2 (50) NOT NULL
, Contact_Number NUMBER (15)NOT NULL
, Address VARCHAR2 (50) NOT NULL
, Nationality VARCHAR2 (15) NOT NULL
...
,    constraint AK1_STUDENTINFO unique (Student_ID, Full_Name, Nationality)

Since Student_ID is unique it follows that Student_ID, Full_Name, Nationality must also be unique. I excluded Fingerprint_Template since I doubt that this can be used in foreign keys (not sure though, if it can you can add it)

create table bit_2015_sep_cit4114_fyp_G_
( Student_ID VARCHAR2 (10) PRIMARY KEY
, Full_Name VARCHAR2 (50) NOT NULL 
, Nationality VARCHAR2 (15) NOT NULL
...
,    constraint fk_studentinfo foreign key (Student_ID, Full_Name, Nationality)
                references studentinfo (Student_ID, Full_Name, Nationality)

);

But as mentioned, start with a normalized design and see if that works


The error has occurred because you are referencing a column in another table which is not unique. The good answers are already given by Lennart and Balazs Papp.

I would like to explain why do we need a unique column in the parent table. As you said you want to keep duplicate values in the column used for the foreign key which is not possible while creating the table. But you can create a reference to an existing table which contains duplicate values.

If you create a primary key with non-unique index and NOVALIDATE option then it is possible. BUT this can lead to confusing results.

Let me explain a situation.

I have created a table with one column ID which has a primary key constraint with a non-unique index.

SQL>CREATE TABLE t1(id NUMBER);
SQL>CREATE INDEX t1_index on t1(id);
SQL>INSERT INTO t1 VALUES(1);
SQL>INSERT INTO t1 VALUES(1);
SQL>COMMIT;
SQL>SELECT id FROM t1;

    ID
----------
     1
     1

SQL>ALTER TABLE t1 ADD CONSTRAINT t1_pk PRIMARY KEY (id) USING INDEX t1_index NOVALIDATE;

Let's create another table to reference the first table.

SQL>CREATE TABLE t2(id NUMBER, CONSTRAINT t2_fk FOREIGN KEY(id) REFERENCES t1(id));

Generate some records.

SQL>INSERT INTO t2 VALUES(1);
SQL>COMMIT;

Table t2 has a value 1 which is referencing parent table t1 which has a duplicate value of 1. Which one the child table's id will refer to?

In the above scenario, the foreign key works fine but the primary key in table t1 works only for new values.

Conclusion: A foreign key must always refer to a column or columns declared as either PRIMARY KEY or UNIQUE in Oracle.


Columns referenced by a foreign key constraint should have a PK or unique constraint in the referenced table. This is not true for Full_Name, Nationality, Fingerprint_Template. To be honest, those FK constraints are unnecessary, remove them, and keep the FK constraint on Student_ID. Also:

"23/10/2015" VARCHAR2 (15) not null, 

This is not a valid column definition. This is:

column_name varchar2(15) default '23/10/2015' not null