How to Design these Tables.

  • I have 2 Tables.

    Account

    AccountID

    1

    2

    3

    4

    etc...

    CategoryTypes

    Field1                                     Field2               Field3

    Agriculture & Primary Industries   Crop Farmers     Cotton

    Agriculture & Primary Industries   Crop Farmers     BeeKeeping

    Auto, Air & Marine                    Automotive        Dynamometers

    Auto, Air & Marine                    Automotive        Engines

    I have no problem in Ascociating an Account with a CategoryType however, How would you go about Designing the CategoryTypes Table? You can clearly see the Duplication here.

    This data will be displayed to a front-end Application.


    Kindest Regards,

  • Hi,

    this looks like example of hierarchy, though I can't be sure from such short example. Is it so that certain value of Field2 always has the same value in Field1.. and so on for Field3? Or can e.g. Crop Farmers appear under Ecology as well as under Agricultures&Primary Industries? Can Engines appear under other than Auto, Air & Marine - Automotive group? And if it can, is it the same Engines or would you have two entries with the same name?

    If there is a normal hierarchy tree, it should probably be done via table with 2 basic columns - value, parent. If it isn't, IMHO you will need several tables to do it properly. Solution may depend also on the way in which it will be used, how often there are changes to this structure etc.

  • Table Account

    - AccountID integer

    - CatType1 varchar(30)

    - CatType2 varchar(30)

    - CatType3 varchar(30)

    Table CatType1

    - CatType1 varchar(30)

    Table CatType2

    - CatType1 varchar(30) ,

    - CatType2 varchar(30)

    Table CatType3

    - CatType3 varchar(30)

    CatType2 is with hierarchy with CatType1 at higher level and CatType2 at lower level

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

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