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

Popular posts from this blog

many to many - Django Rest Framework ManyToMany filter multiple values -

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

Java Entity Manager - JSON reader was expecting a value but found 'db' -