Primary Foreign key relationship in mysql.
Posted: Sat Nov 19, 2011 10:07 am
Dear members,
I have the following tables with constraints:
create table test(
student_no numeric,
student_name varchar(50),
ad_date date);
alter table test
add constraint testpk primary key (student_no);
create table test2(
student_no numeric,
student_name varchar(50),
ad_date date);
ALTER TABLE test2
ADD CONSTRAINT FOREIGN KEY
(student_no)
REFERENCES test (student_no);
---------------------------------
but at the time of insertion in table test2 it don't validate from the parent table.
I am using mysql Server version: 5.1.41.
please guide me whats the problem.
Regards:
I have the following tables with constraints:
create table test(
student_no numeric,
student_name varchar(50),
ad_date date);
alter table test
add constraint testpk primary key (student_no);
create table test2(
student_no numeric,
student_name varchar(50),
ad_date date);
ALTER TABLE test2
ADD CONSTRAINT FOREIGN KEY
(student_no)
REFERENCES test (student_no);
---------------------------------
but at the time of insertion in table test2 it don't validate from the parent table.
I am using mysql Server version: 5.1.41.
please guide me whats the problem.
Regards: