简体   繁体   中英

Foreign key integration in phpmyadmin

I have 3 tables named products, products_distribution, region. Logic is product has one pkey p_id, region has one pkey r_id, and products_distribution must have one pkey lets say pd_id and 2 foreign keys relating to products and regions.

I can have many products for one region.

I have created unique key for product_id and region id and mentioned foreignkey that related product and region table. But after I created I added product id 7 and region id 7 in product distribution table. Again I wanted to create row with product id 7 and region id 8. But, it says duplicate entry. I have set pd_id (pkey) set to auto increment.

How to integrate foreign key in phpmyadmin in this scenario, so that i can able to set same number of product_id in other rows. But, combination of product_id and region_id in product distribution table must be primary key.

By default, the index creation dialog of phpMyAdmin is set to create a unique index. You just have to change the "index type" selector of this dialog to "index".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM