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

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

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -