SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast 1magic's Avatar
    Join Date
    Jan 2002
    Posts
    54
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with database design needed

    Could someone give me a hint about database design:

    Say I have a database with products. I have names, prices, category, etc.
    I want to add tech. specifications to my products. For every product there are at least 8-10 specifications and values.

    For example:

    name: Wide Leather Belt

    Tech. specs:
    weight: ?? kgs.
    color: ???
    etc.

    Is it better to keep them in the same table with the product, or separate?

  2. #2
    Made with a Mac! philm's Avatar
    Join Date
    Sep 2001
    Location
    Portsmouth, UK
    Posts
    735
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There's plenty of sources around that'll make a better job explaining it than i ever will

    http://www.webmasterbase.com/article.php/378

    have fun!

  3. #3
    SitePoint Enthusiast xev's Avatar
    Join Date
    Jan 2002
    Location
    USA
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If there is a different number of specs for each record, then you should definately put them in a seperate table.

    Maybe the specs table could have the spec type as an enum, then the value as a varchar.

    tblProducts
    -----------
    prNum INT
    prName VARCHAR(50)
    prPrice FLOAT(9,2)
    prCategory VARCHAR(100)
    PRIMARY KEY(prNum)

    tblSpecs
    --------
    spNum INT
    spProduct INT <- should relate to prNum
    spType ENUM('weight','color')
    spValue VARCHAR(20)
    INDEX(spProduct ),PRIMARY KEY(spNum)

  4. #4
    SitePoint Enthusiast 1magic's Avatar
    Join Date
    Jan 2002
    Posts
    54
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In a separate table... OK, thanks.


Bookmarks

Posting Permissions

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