foreign keys - MySQL how to make a column of child table point to the parent table? -
i've started mysql database , confused foreign key do.
suppose have parent table (teacher) of , taxno primary key;
taxno tfname tlname tgender tquali thours 1111 toh jim m honours 120
and childtable (teacsub);
taxno tfname tlname tgender tquali thours subtitle subtype
how make if, example, input teacsub is
taxno tfname tlname tgender tquali thours subtitle subtype 1111 dddd dddd f weqwe 100 history 3
it prompmt me input teacsub wrong?
i have created foreign key taxno applies taxno.
the beauty of relational db constructed tables, not need repeat information have been doing.
if teacher
table contains information persons name, gender etc, not need duplicate information anywhere else.
for example, if teacsub
table teacsub(taxno, subtitle, subtype)
, can 'full' information joining 2 tables query this:
select * teacher inner join teacsub on teacher.taxno = teacsub.taxno
and happily go off , pull rows both tables share common taxno
Comments
Post a Comment