Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2012
    Posts
    1

    Question Unanswered: Entities with different properties depending on entity type

    I am interested to know what the best practice is for the situation where:
    • I have a bunch of entities (like orders)
    • Orders have various properties
    • The properties each order has depends on the *type* of order


    Is the best practice to have one order table schema and all of the possible properties (with the result being some will be empty, depending on the order type), and then decide which properties to select in the application logic?

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    The answer really depends on two things. Most important is how picky you are about following the "true religion" of relational design. If you use an application framework, a close second is how does that framework deal with this kind of problem.

    The pure relational approach would be to create a parent table with information that was common to all orders, then creating additional tables with foreign keys to the parent table that included all of the information that is specific to a given type of order.

    If you are coding your interface by hand, I'd strongly suggest that you reconsider using a framework of some type... They can save you hundreds or thousands of hours over the course of a product's lifetime in terms of developing, debugging, and supporting that product.

    The short answer boils down to you need to do what works for you. I recommend using subtables, but for simple products/projects that may well be overkill.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •