primary and foreign key relationship in mysql -
i want create 2 tables, 1 having primary key , other foreign key.
so requirement values in users should available present in customers table other vice show error constraint violation.
did this, still able insert values in users not in customers.
create table if not exists customers ( cust_user_id int, primary key (cust_user_id) ); create table if not exists users ( prid int, foreign key (prid) references customers(cust_user_id) on update cascade );
any suggestion ?
thanks
Comments
Post a Comment