Reputation: 421
dispatches 1------M dispatch_items
sub_jobs 1-------M dispatch_items
dispatches M-----N sub_jobs
I need to have all of these relationships
dispatch_subjob table (Is the intermediary table between dispatches and sub_jobs) and it has below mentioned columns
id
dispatch_id
sub_job_id
dispatch_items tablehas below mentioned columns
id
dispatch_id
sub_job_id
qty
description
My issue is that i see dispatch_id and sub_job_id is repeated in both tables(Table structure looks wrong)
Practically i need to have both these tables like above mentioned to get results in a much practical way
E.g.: - sub_jobs table has a qty field and i need to do some caculations with dispatch_items table qty (Use of 1 to M)
E.g.:- I need to get all sub_jobs of when a dispatch_id is given (Use of M to M)
Upvotes: 0
Views: 28
Reputation: 539
It looks like your dispatch_items and dispatch_subjob tables are performing the same role, as a pivot between the two. If that's the case, dispatch_subjob is not necessary as you have the additional cols on dispatch_item (although it's probably more correct naming to keep dispatch_subjob).
Upvotes: 1