foreign key constraint
foreign key constraint
(OP)
hi,
I am new to mysql but have experience on oracle and am implemnting a web db solution with mysql.
I create two tables
Cities which has 2 fields
citycode mediumint primary key
cityname varchar(20)
and
pincodes
pincode mediumint primary key
areaname varchar(20)
citycode mediumint references cities (citycode )
match full
the not null constraint is specified for the primary and foreign key fields .
My problem is even after doing this the pincodes table
is allowing entries for citycodes not in the cities master
table .
where am i going wrong or are there any other constraints
needed to implement this.
bye
I am new to mysql but have experience on oracle and am implemnting a web db solution with mysql.
I create two tables
Cities which has 2 fields
citycode mediumint primary key
cityname varchar(20)
and
pincodes
pincode mediumint primary key
areaname varchar(20)
citycode mediumint references cities (citycode )
match full
the not null constraint is specified for the primary and foreign key fields .
My problem is even after doing this the pincodes table
is allowing entries for citycodes not in the cities master
table .
where am i going wrong or are there any other constraints
needed to implement this.
bye