MySQL Forums
Forum List  »  InnoDB

How to give relationships to entity?
Posted by: Hakoo Desai
Date: April 11, 2011 10:58PM

Hello All,

I have three tables : COMPANY, PRODUCT and MODEL.

-->In Company Table ,
ID(Auto Increment), company(Unique)

-->In Product Table ,
ID(Auto Increment),product, product_ID, company
Index of(Product,Product_ID,Company) is unique and Product.company is foreign key of Company.company(ON Delete/Update Cascade) , so Product can be inserted under two different companies

The main purpose of product_ID is Identification of Products under Company. So, even if Product Name changes, it can be identified by Product_ID.

-->In Model Table ,
ID(Auto Increment),Model,Product, ?(Should I include here Product_ID), Company
Here How to give foreign key so that if I change Product.product under one company so that same change propagates to Model Table.

To clear the idea,

I have data under Product Table,

1 a a1 Sony
2 b a2 Sony
3 a a1 Wipro
4 b a2 Wipro

I have data under Model Table,
1 abc a Sony
2 def a Sony
3 abc b Wipro
4 abcd a Wipro

Now i want to make relationship such that if I change Product a under Company Sony than that propagates to Model Tabel where Product and Company matches.

Please help me,
Thanking,
Hakoo Desai.

Options: ReplyQuote


Subject
Views
Written By
Posted
How to give relationships to entity?
2445
April 11, 2011 10:58PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.