sql - shared relationships in database -
sorry ignorant.... trying set database of 5 tables.... truck_fleets, cabs, trailers, tyres, tyre_pressures. should straight forward except "tyres" needs child of both "cab" , "trailer". both cab of truck , trailer of truck have tyres!
in setting end 2 keys in "tyres" 1 of satisfied. tyre belongs either cab or the trailer.
any suggestions or reference can read please.
thanks
try 2 relation tables. 1 connects cabs tyres, call cab_tyres , 1 connects trailers tyres, call trailer_tyres.
each table holds 2 id's.
cab_tyres: int cab_id //fk cab table int tyre_id //fk tyre table trailer_tyres: int trailer_id //fk trailer table int tyre_id //fk tyre table
to elaborate little, theory here entity relations entities, , typed according things relate. don't mix types normally, have 2 relation tables.
if wish relate cab , it's trailer, relation entity , on.
Comments
Post a Comment