movement of foreign key
-
i have three tables 1) products ======================= with following columns: product_id product_cat product_cat_brand product title product_price product_image product_Category ======================= with following columns cat_id cat_title product_Brand ======================= with following columns: brand_id brand_title =============== Question???: ================ so my question is: which table will receive the foreign key of which other table? or in other words how i can make relations between these tables..
-
i have three tables 1) products ======================= with following columns: product_id product_cat product_cat_brand product title product_price product_image product_Category ======================= with following columns cat_id cat_title product_Brand ======================= with following columns: brand_id brand_title =============== Question???: ================ so my question is: which table will receive the foreign key of which other table? or in other words how i can make relations between these tables..
From what you show only the following can be done/makes sense:
products
(
....
CONSTRAINT FK_products_cat FOREIGN KEY (product_cat) REFERENCES product_Category(cat_id)
)You need to think again about the layout. It seems that products needs something like product_Brand instead of product_cat_brand. In case this assumption is right then:
products
(
....
CONSTRAINT FK_products_cat FOREIGN KEY (product_cat) REFERENCES product_Category(cat_id)
CONSTRAINT FK_products_brand FOREIGN KEY (product_brand) REFERENCES product_Brand(brand_id)
)