Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. A Database Design Problem - Catalogue

A Database Design Problem - Catalogue

Scheduled Pinned Locked Moved Database
databasedesignhelptutorialquestion
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Cristoff
    wrote on last edited by
    #1

    I'll try to describe my problem. I'm trying to make a program that will display online the articles that are on stock in our company. All these things have completely different properties, so they cannot be put in the same table. Just to illustrate: Let's say I'm trying to combine apples, oranges, sports cars and rockets. First ones have sorts, cars have horse powers and gas engines and rockets... it doesn't matter. All these are articles/products. I my case I'm talking about resistors, capacitors, CPU s, micro controllers, LCDs, aluminum boxes, light diodes, electronic units, etc. As you see all these should belong to different product categories and each category in a separate table. And also this is my very database first project and it turned out to be much more complex than I've anticipated initially. I've searched a lot of DB examples but I cannot find any similar scenario. Please give me an idea how to approach this problem! Is it possible to use the standard approach - product table - categories tables or such relation is impossible? The only idea I have so far is to create different tables for each category and to keep them separated and the link between them to be on the application level and not on the SQL database level. :wtf: Thank you for reading all that! :-O

    M C 2 Replies Last reply
    0
    • C Cristoff

      I'll try to describe my problem. I'm trying to make a program that will display online the articles that are on stock in our company. All these things have completely different properties, so they cannot be put in the same table. Just to illustrate: Let's say I'm trying to combine apples, oranges, sports cars and rockets. First ones have sorts, cars have horse powers and gas engines and rockets... it doesn't matter. All these are articles/products. I my case I'm talking about resistors, capacitors, CPU s, micro controllers, LCDs, aluminum boxes, light diodes, electronic units, etc. As you see all these should belong to different product categories and each category in a separate table. And also this is my very database first project and it turned out to be much more complex than I've anticipated initially. I've searched a lot of DB examples but I cannot find any similar scenario. Please give me an idea how to approach this problem! Is it possible to use the standard approach - product table - categories tables or such relation is impossible? The only idea I have so far is to create different tables for each category and to keep them separated and the link between them to be on the application level and not on the SQL database level. :wtf: Thank you for reading all that! :-O

      M Offline
      M Offline
      Mike Dimmick
      wrote on last edited by
      #2

      I think you're falling into the trap of trying to model the 'real world'. In software systems we don't model all the properties of the real-world objects we deal with, only those properties that are significant to the problem we're trying to solve. In a retail system only a few things are significant: an identifier to uniquely identify this product, (commonly) a more user-friendly description, the price we plan to sell it at, and the level of stock we have. If you need to categorise, put a 'category' indicator on the product table. Generally you shouldn't split up a logical collection of items into multiple tables. It becomes very hard to join them back together. If for any reason you actually do need to, for example if one category is queried much more heavily than others and it would benefit from being placed on a different disk, consider the database's partitioning support (if any). I believe it was possible to simulate partitioning efficiently in SQL Server 2000 but can't remember the details. If you need to store additional information that won't be uniform across all items, consider nullable columns and using NULL where the value doesn't apply, or what I call 'extension tables' which are associated with the main, common, table in a one-to-one relationship, which stores only the extended information about this type of item.

      DoEvents: Generating unexpected recursion since 1991

      C 1 Reply Last reply
      0
      • C Cristoff

        I'll try to describe my problem. I'm trying to make a program that will display online the articles that are on stock in our company. All these things have completely different properties, so they cannot be put in the same table. Just to illustrate: Let's say I'm trying to combine apples, oranges, sports cars and rockets. First ones have sorts, cars have horse powers and gas engines and rockets... it doesn't matter. All these are articles/products. I my case I'm talking about resistors, capacitors, CPU s, micro controllers, LCDs, aluminum boxes, light diodes, electronic units, etc. As you see all these should belong to different product categories and each category in a separate table. And also this is my very database first project and it turned out to be much more complex than I've anticipated initially. I've searched a lot of DB examples but I cannot find any similar scenario. Please give me an idea how to approach this problem! Is it possible to use the standard approach - product table - categories tables or such relation is impossible? The only idea I have so far is to create different tables for each category and to keep them separated and the link between them to be on the application level and not on the SQL database level. :wtf: Thank you for reading all that! :-O

        C Offline
        C Offline
        ChandraRam
        wrote on last edited by
        #3

        You could have one table of Categories and another of CategoryProperties (multiple rows for each Category, containing CategoryId, Property Name and Value) - will that work for you?

        C 1 Reply Last reply
        0
        • C ChandraRam

          You could have one table of Categories and another of CategoryProperties (multiple rows for each Category, containing CategoryId, Property Name and Value) - will that work for you?

          C Offline
          C Offline
          Cristoff
          wrote on last edited by
          #4

          I don't understand how to do that yet.

          C 1 Reply Last reply
          0
          • M Mike Dimmick

            I think you're falling into the trap of trying to model the 'real world'. In software systems we don't model all the properties of the real-world objects we deal with, only those properties that are significant to the problem we're trying to solve. In a retail system only a few things are significant: an identifier to uniquely identify this product, (commonly) a more user-friendly description, the price we plan to sell it at, and the level of stock we have. If you need to categorise, put a 'category' indicator on the product table. Generally you shouldn't split up a logical collection of items into multiple tables. It becomes very hard to join them back together. If for any reason you actually do need to, for example if one category is queried much more heavily than others and it would benefit from being placed on a different disk, consider the database's partitioning support (if any). I believe it was possible to simulate partitioning efficiently in SQL Server 2000 but can't remember the details. If you need to store additional information that won't be uniform across all items, consider nullable columns and using NULL where the value doesn't apply, or what I call 'extension tables' which are associated with the main, common, table in a one-to-one relationship, which stores only the extended information about this type of item.

            DoEvents: Generating unexpected recursion since 1991

            C Offline
            C Offline
            Cristoff
            wrote on last edited by
            #5

            Thank you! What I have in mind for example is the product browser of the website http://www.farnell.com This site is huge. Mine will be very small with not that many items (compared to Farnell) and with few users. I have difficulty to accept the idea with NULLable columns yet, because because I might end with dozens and dozens if not hundreds of columns. Thank you for the remark. A friend of mine also told me: "Forget about that OOP way of thinking". I'll think about my problem a little while longer.

            1 Reply Last reply
            0
            • C Cristoff

              I don't understand how to do that yet.

              C Offline
              C Offline
              ChandraRam
              wrote on last edited by
              #6

              For example... Table 1: Category Fields: CategoryId (PK), CategoryName Sample data:

              1 Car
              2 Apples

              Table 2: CategoryProperties Fields: CategoryId (FK), PropertyId (PK), PropertyName, PropertyValue Sample data:

              1 1 HorsePower 1500
              2 2 Sort 10

              Hopefully, the above clarifies my thought on this... don't know if it helps you.

              C 1 Reply Last reply
              0
              • C ChandraRam

                For example... Table 1: Category Fields: CategoryId (PK), CategoryName Sample data:

                1 Car
                2 Apples

                Table 2: CategoryProperties Fields: CategoryId (FK), PropertyId (PK), PropertyName, PropertyValue Sample data:

                1 1 HorsePower 1500
                2 2 Sort 10

                Hopefully, the above clarifies my thought on this... don't know if it helps you.

                C Offline
                C Offline
                Cristoff
                wrote on last edited by
                #7

                Thank you! Interesting suggestion. I'll think about it. It could do the job!

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups