Schema Design - Product Packing Box

  • Dear Experts,

    I would to know your valuable suggestions for requirement as mentioned below.
    Most of the products delivered using packing box and few without box (use wrapping).
    Each packing box suites for few products but each product will have only one packing box only.
    Which sample suites best?

    /* Sample 1
    Packing Box:
       PackingBoxID (PK), BoxNumber (UQ), Length, Width, Height, Gross Weight
    Product:
       ProductID (PK), ProductNumber (UQ), ...,PackingBoxID
    */

    /* Sample 2
    Packing Box:
       PackingBoxID (PK), BoxNumber (UQ), Length, Width, Height, Gross Weight
    Product:
       ProductID (PK), ProductNumber (UQ), ...,
    ProductPackingBox:
       ProductID, PackingBoxID
     */

    Thank you.

  • Correct me if I'm wrong, but a given product will have multiple instances. Let's assume a can of oil. We can define all the properties about that can of oil, but, we don't have one can that we put into a shipping box. We have lots of cans that go into lots of shipping boxes. Based on that, you probably need some sort of Inventory table (or maybe just a counter on the Product table, disagreement can be had here) that defines what you're shipping. Then, the second design, multiple products to multiple shipping boxes, makes more sense.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Sample 2

  • kiran 4243 - Monday, January 8, 2018 9:14 PM

    Dear Experts,

    I would to know your valuable suggestions for requirement as mentioned below.
    Most of the products delivered using packing box and few without box (use wrapping).
    Each packing box suites for few products but each product will have only one packing box only.
    Which sample suites best?

    /* Sample 1
    Packing Box:
       PackingBoxID (PK), BoxNumber (UQ), Length, Width, Height, Gross Weight
    Product:
       ProductID (PK), ProductNumber (UQ), ...,PackingBoxID
    */

    /* Sample 2
    Packing Box:
       PackingBoxID (PK), BoxNumber (UQ), Length, Width, Height, Gross Weight
    Product:
       ProductID (PK), ProductNumber (UQ), ...,
    ProductPackingBox:
       ProductID, PackingBoxID
     */

    Thank you.

    If a particular product is always delivered in the same box type, one product per box, then PackingBoxID is an attribute of the Products table.

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply