Take a look at
PRIMARY KEY Constraint[
^] &
FOREIGN KEY Constraint[
^] in SQL.
Tutorial says:
The FOREIGN KEY constraint also prevents that invalid data form being inserted into the foreign key column, because it has to be one of the values contained in the table it points to.
Here you are trying to insert some value into the column(foreign key) which is not present in the column(primary key) of another table, but it raised you an exception
Parent Table
---------------
ColumnA ColumnB
100 1000
200 2000
Child Table
---------------
ColumnC ColumnD ColumnA
1 1 100 <---- Value 100 exists in Parent table
2 2 300 <---- But value 300 not exists in Parent table, so it'll raise error. So insert existing value here