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

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

matplotlib support failed in PyCharm on OSX -

python - Matplotlib: TypeError: 'AxesSubplot' object is not callable -