MySQL Database Normalization and Primary ID's
I have a quick question. I have a database with three tables Shops, Tire_Brands, and Accepted_Tires and for accepted_tires it will just have "id, tire_id, shop_id".
Is it 开发者_高级运维necessary to have the "id" field for accepted_tires. Will I ever use it, or is it OK to just have "tire_id" and "shop_id" and that's it?
Hope that makes sense. Thanks!
The id
field is not necessary in this case. You could have a complex primary key composed of both tire_id
and shop_id
columns because this couple must be unique.
Unfortunately, you don't make the structure of your db very clear; if the accepted_tires table is only being used to resolve a many-to-many relationship between the other 2 tables, then no, it doesn't need its own ID
Is any table dependent on Accepted_Tires table? From what I see, it is a NO, now. But, will any table be dependent of Accepted_Tires in future - like a master child? If yes, go for ID now.
精彩评论