views:

33

answers:

1

I have Brand and Company. 1 Company can have 1 or more Brands.

As an example, company has company_id, company_name. Similarly Brands has brand_id and brand_name. Now can i add the FK column company_id to brands also and the relationship is complete in 2 tables or do i need a 3rd table like Company_Brands which will have company_id, brand_id and the default PK?

I am not asking for an ideal text book way this should be done but in a high transaction environment where performance is important so less query stain and also where writes will be high along with data will change in tables as this is a user content site so information may not be accurate and thus edited constantly.

+5  A: 

Just add the foreign key company_id to the brands table. You have described a 1 to many relationship i.e. 1 company can have many brands, but 1 brand cannot have many companies.
You would only need the junction table if you had a many to many relationship.

macleojw