Are multiple Many-Many relationships evidence of bad design? <p>Good day all,</p> <p>I have been learning about databases and database design and I find I am still reaching a question I cannnot answer myself. So I pose the question to the community in hopes that someone with more knowledge/experience than I can answer it.</p> <p>I have been tasked with working on a database which tracks stock levels accross a fleet of ships.</p> <p>The current design has a table for each ship with a list of all possible parts (Machinery Type, Part Number, Make, Serial No etc.)</p> <p>This means that the details of a piece of machinery or part can be duplicated many times (as many times as there are ships in fact).</p> <p>I have been experimenting with a redesign based on what I have learnt myself, and I would propose a design along the following lines:</p> <pre><code>[SHIP] ID, Name, Class, Tonnage, Fleet, Superintendent etc. [Machinery] ID, Type, Make, Model etc. (Can have separate table for manufacturers and types if required) [Part] ID, Part number, Description, etc. </code></pre> <p>The above would be the three main tables now is where it starts to get difficult. </p> <p>Each ship can have multiple items of machinery and each machinery item could be present on multiple ships (requires a junction table)</p> <p>Each machinery item can have multiple parts and each part could belong to multiple machinery items (another junction table)</p> <p>There could be well into hundreds of thousands of parts which would make the junction tables huge.</p> <p>Additionally as soon as you want to keep track of stock you are looking at another junction table</p> <pre><code>[Stock Level] ShipID, PartID, Stock Level </code></pre> <p>Also if you wanted a minimum stock (Could be combined with Stock Level?)</p> <pre><code>[Min Stock] ShipID, PartID, Min Stock </code></pre> <p>And finally if you were looking to have normalised database (i.e no Part No.1 , Part No.2 or Serial No.1, Serial No.2)</p> <p>You would need to have a few extra tables</p> <pre><code>[Serial Numbers] ShipID, MachineryID, Serial No [Part Numbers] PartID, Part Number </code></pre> <p>Serial numbers is probably going to be fairly standard and no problem however [part numbers] will require at least as many records as are in the [Parts] table.</p> <p>Map (As best as I can represent without a picture, junctions omitted for simplicity)</p> <pre><code> &lt;&gt;V represent many -| represent one -----&lt; Serial Numbers | V | | Ship &gt;---&lt; Machinery &gt;---&lt; Parts ---&lt; Part Numbers V V | | ------ Stock Level ------- </code></pre> <p>Now the real question is am I missing something in the basic design principles that would eliminate such huge junction tables or is this to be expected with this kind of database.</p> <p>Also in cases like with part numbers where normalisation requires an additional table with at least the same number of records rather than extra columns in the original table is this the kind of thing that you would later denormalise to improve query speed?</p> <p>Any hints, tips or pointers to external resources (including other forums, tutorials, books) would be greatly appreciated.</p> <p>All answers welcome, thank you in advance for any help you provide.</p> <p>Dave</p>