Slightly OT - Database Question

Ask a Question related to Dreamweaver AppDev, Design and Development.

  1. #1

    Default Slightly OT - Database Question

    I'm designing a simple database which has 13 fields
    I am tempted to use just one table but i know that this is NOT the way to do
    things.
    I'd like to learn a quick method of good database design.

    I have created three tables from my fields as below.
    Would this be the correct design?
    How should i make the relationships and from which table/field to which?

    Hope someone can point me in the right direction.

    Cheers in advance
    Andy

    The fields are:
    ID
    Category
    Category_Image
    Category_Text
    Product_Title
    Product_Description
    Product_Image
    Product_Price
    Show_Product_Price
    Retailer_Name
    Retailer_Logo
    User_Name
    User_Password

    I have these divided into the three tables as:

    CategoryID
    Category
    Category_Image
    Category_Text

    ProductID
    Product_Title
    Product_Description
    Product_Image
    Product_Price
    Show_Product_Price

    UserID
    Retailer_Name
    Retailer_Logo
    User_Name
    User_Password



    Andy Guest

  2. Similar Questions and Discussions

    1. Database question
      Hi Group, Currently i am connecting the underlying database server from every php page. To reduce the connection overhead i am thinking to store...
    2. Database and asp question
      Hi 1 and all, (Thanks to Bob Burrows directing me to this newsgroup ;-) ) Having played with and now 'reasonably' comfortable with asp and...
    3. [Slightly OT] Is there a way?
      Is there a way for me to download a PHP interpreter for Linux that I can paste into /usr/bin/ since my installation used the shared object module...
    4. slightly ot
      this is related to php in the sense that I use it in my development I need to use the https protocol to transfer a ssn over a web form..I just...
    5. plain paper for Canon i950 slightly OT printer question
      Lionel <nop@alt.net> wrote in message news:<beiu6u$pbk$3@pita.alt.net>... any recs or warnings re using plain paper in the Canon i950. We needed...
  3. #2

    Default Re: Slightly OT - Database Question

    Good database design isn't "quick and easy" but there are tutorials around
    and good books on the subject that should help you. What you have below
    looks pretty good for three tables called Categories, Products and
    Retailers. However .. in order to relate one to another, you will have to
    have Foreign Keys implanted. A Foreign Key is an ID from another table that
    relates to that particular record and has a column in the current table to
    allow for plugging in that record.

    For example, in your Products table, you would wish to have CategoryID as a
    Foreign Key and the value would be the particular category ID of the
    category to which that product belongs. Suppose, for example, you have
    defined Category1 to be "Toys". and Product1 is a "ball" but Product2 is a
    "vacuum cleaner". Product1 would have Category1 as the Foreign Key in irs
    record, but Product2 would have a different CategoryID as foreign key
    because it is not a toy.

    Make sense?


    --
    Nancy Gill
    Team Macromedia Volunteer for Dreamweaver MX/UltraDev
    [url]http://www.macromedia.com/go/team/[/url]
    Co-Author: Dreamweaver MX: Instant Troubleshooter (August, 2003)
    Technical Editor: DMX 2004: The Complete Reference, DMX 2004: A Beginner's
    Guide, Mastering Macromedia Contribute
    Technical Reviewer: Dynamic Dreamweaver MX/DMX: Advanced PHP Web Development

    "Andy" <AndyjhughesNOSPAM@ntlworld.com> wrote in message
    news:cvl2dl$4l3$1@forums.macromedia.com...
    > I'm designing a simple database which has 13 fields
    > I am tempted to use just one table but i know that this is NOT the way to
    do
    > things.
    > I'd like to learn a quick method of good database design.
    >
    > I have created three tables from my fields as below.
    > Would this be the correct design?
    > How should i make the relationships and from which table/field to which?
    >
    > Hope someone can point me in the right direction.
    >
    > Cheers in advance
    > Andy
    >
    > The fields are:
    > ID
    > Category
    > Category_Image
    > Category_Text
    > Product_Title
    > Product_Description
    > Product_Image
    > Product_Price
    > Show_Product_Price
    > Retailer_Name
    > Retailer_Logo
    > User_Name
    > User_Password
    >
    > I have these divided into the three tables as:
    >
    > CategoryID
    > Category
    > Category_Image
    > Category_Text
    >
    > ProductID
    > Product_Title
    > Product_Description
    > Product_Image
    > Product_Price
    > Show_Product_Price
    >
    > UserID
    > Retailer_Name
    > Retailer_Logo
    > User_Name
    > User_Password
    >
    >
    >

    Nancy Gill Guest

  4. #3

    Default Re: Slightly OT - Database Question

    Nancy Gill wrote:
    > Good database design isn't "quick and easy" but there are tutorials around
    > and good books on the subject that should help you.
    i agree with Nancy and suggest you "Database Design for Mere Mortals" by
    Michael J. Hernandez
    Manuel Socarras Guest

  5. #4

    Default Re: Slightly OT - Database Question

    .oO(Andy)
    >I'm designing a simple database which has 13 fields
    >I am tempted to use just one table but i know that this is NOT the way to do
    >things.
    Correct. Putting it all into a single table wastes a lot of resources
    becaues of the redundant information and will cause many problems on
    insert and update operations (called 'anomalies').
    >I'd like to learn a quick method of good database design.
    Good DB design can't be done between breakfast and dinner, it definitely
    takes some time. Search for some sites/tutorials about DB design,
    especially about normalization/normal forms.
    >I have created three tables from my fields as below.
    >Would this be the correct design?
    I would not say a DB design can be 'correct', but it can be good or bad.
    At least splitting it like you did below is the correct way.
    >How should i make the relationships and from which table/field to which?
    To connect two tables there has to be a kind of shared column(s) in both
    of them, holding the same values (read up on 'primary keys' and 'foreign
    keys'). In your case the products table would need a column categoryID,
    which stores the ID of the category the product belongs to. This ID can
    then be used to identify the associated record in the categories table.
    Such a layout is called 1:m relationship (one-to-many): a product can be
    part of only one category, but each category can hold many products.

    Another and probably better option is to use a third table to connect
    the products and categories table, something like

    table products
    --------------
    productID
    title
    description
    ....

    table categories
    ----------------
    categoryID
    title
    description
    ....

    table belongs
    -------------
    productID
    categoryID

    This is called a m:n relationship (many-to-many). With this it's
    possible to assign multiple categories to one product (and of course to
    have multiple products in each category). The products and categories
    tables use an ID as their primary key, the same IDs are used in the
    third table as foreign keys (references). This table contains a record
    for every combination of a product and a category. While such a layout
    may look rather complicated, it's very flexible and efficient.

    HTH
    Micha
    Michael Fesser Guest

  6. #5

    Default Re: Slightly OT - Database Question

    Thank you so much to you all. You've helped to make things look a little
    clearer.
    I'm glad that im at least on the right path :-)

    I have found one other question that has me stumped!
    Each UserID will have their own pricing sceme for the same products. I can't
    get my head round how i could acheive this.
    Their would be too many prices for them to simply select one from a dropdown
    list, so how could i allow each User (about 250) individual pricing for the
    products?

    Hope this makes some sense and thanks very much to you all.

    Kind Regards
    Andy


    "Michael Fesser" <netizen@gmx.net> wrote in message
    news:mj9s115eg97ljbfke741mm9e29ubut8nro@4ax.com...
    > .oO(Andy)
    >
    >>I'm designing a simple database which has 13 fields
    >>I am tempted to use just one table but i know that this is NOT the way to
    >>do
    >>things.
    >
    > Correct. Putting it all into a single table wastes a lot of resources
    > becaues of the redundant information and will cause many problems on
    > insert and update operations (called 'anomalies').
    >
    >>I'd like to learn a quick method of good database design.
    >
    > Good DB design can't be done between breakfast and dinner, it definitely
    > takes some time. Search for some sites/tutorials about DB design,
    > especially about normalization/normal forms.
    >
    >>I have created three tables from my fields as below.
    >>Would this be the correct design?
    >
    > I would not say a DB design can be 'correct', but it can be good or bad.
    > At least splitting it like you did below is the correct way.
    >
    >>How should i make the relationships and from which table/field to which?
    >
    > To connect two tables there has to be a kind of shared column(s) in both
    > of them, holding the same values (read up on 'primary keys' and 'foreign
    > keys'). In your case the products table would need a column categoryID,
    > which stores the ID of the category the product belongs to. This ID can
    > then be used to identify the associated record in the categories table.
    > Such a layout is called 1:m relationship (one-to-many): a product can be
    > part of only one category, but each category can hold many products.
    >
    > Another and probably better option is to use a third table to connect
    > the products and categories table, something like
    >
    > table products
    > --------------
    > productID
    > title
    > description
    > ...
    >
    > table categories
    > ----------------
    > categoryID
    > title
    > description
    > ...
    >
    > table belongs
    > -------------
    > productID
    > categoryID
    >
    > This is called a m:n relationship (many-to-many). With this it's
    > possible to assign multiple categories to one product (and of course to
    > have multiple products in each category). The products and categories
    > tables use an ID as their primary key, the same IDs are used in the
    > third table as foreign keys (references). This table contains a record
    > for every combination of a product and a category. While such a layout
    > may look rather complicated, it's very flexible and efficient.
    >
    > HTH
    > Micha
    >


    Andy Guest

  7. #6

    Default Re: Slightly OT - Database Question

    Set up another table. :)
    Leave "price" out of the product table (unless you want it there as a
    fallback) and make a new table
    UserPrices
    -------------
    UserID
    ProductID
    Price

    Then, you just have to link the user, product, and userprices tables to get
    the appropriate product prices for each user.

    "Andy" <AndyjhughesNOSPAM@ntlworld.com> wrote in message
    news:cvmq2p$kou$1@forums.macromedia.com...
    > Thank you so much to you all. You've helped to make things look a little
    > clearer.
    > I'm glad that im at least on the right path :-)
    >
    > I have found one other question that has me stumped!
    > Each UserID will have their own pricing sceme for the same products. I
    can't
    > get my head round how i could acheive this.
    > Their would be too many prices for them to simply select one from a
    dropdown
    > list, so how could i allow each User (about 250) individual pricing for
    the
    > products?
    >
    > Hope this makes some sense and thanks very much to you all.
    >
    > Kind Regards
    > Andy
    >
    >
    > "Michael Fesser" <netizen@gmx.net> wrote in message
    > news:mj9s115eg97ljbfke741mm9e29ubut8nro@4ax.com...
    > > .oO(Andy)
    > >
    > >>I'm designing a simple database which has 13 fields
    > >>I am tempted to use just one table but i know that this is NOT the way
    to
    > >>do
    > >>things.
    > >
    > > Correct. Putting it all into a single table wastes a lot of resources
    > > becaues of the redundant information and will cause many problems on
    > > insert and update operations (called 'anomalies').
    > >
    > >>I'd like to learn a quick method of good database design.
    > >
    > > Good DB design can't be done between breakfast and dinner, it definitely
    > > takes some time. Search for some sites/tutorials about DB design,
    > > especially about normalization/normal forms.
    > >
    > >>I have created three tables from my fields as below.
    > >>Would this be the correct design?
    > >
    > > I would not say a DB design can be 'correct', but it can be good or bad.
    > > At least splitting it like you did below is the correct way.
    > >
    > >>How should i make the relationships and from which table/field to which?
    > >
    > > To connect two tables there has to be a kind of shared column(s) in both
    > > of them, holding the same values (read up on 'primary keys' and 'foreign
    > > keys'). In your case the products table would need a column categoryID,
    > > which stores the ID of the category the product belongs to. This ID can
    > > then be used to identify the associated record in the categories table.
    > > Such a layout is called 1:m relationship (one-to-many): a product can be
    > > part of only one category, but each category can hold many products.
    > >
    > > Another and probably better option is to use a third table to connect
    > > the products and categories table, something like
    > >
    > > table products
    > > --------------
    > > productID
    > > title
    > > description
    > > ...
    > >
    > > table categories
    > > ----------------
    > > categoryID
    > > title
    > > description
    > > ...
    > >
    > > table belongs
    > > -------------
    > > productID
    > > categoryID
    > >
    > > This is called a m:n relationship (many-to-many). With this it's
    > > possible to assign multiple categories to one product (and of course to
    > > have multiple products in each category). The products and categories
    > > tables use an ID as their primary key, the same IDs are used in the
    > > third table as foreign keys (references). This table contains a record
    > > for every combination of a product and a category. While such a layout
    > > may look rather complicated, it's very flexible and efficient.
    > >
    > > HTH
    > > Micha
    > >
    >
    >
    >

    CMBergin Guest

  8. #7

    Default Re: Slightly OT - Database Question

    Thanks CM

    Very much appreciated !

    Andy - :-)

    "CMBergin" <NoHarvestForYou@NoSpam.org> wrote in message
    news:cvn885$c2k$1@forums.macromedia.com...
    > Set up another table. :)
    > Leave "price" out of the product table (unless you want it there as a
    > fallback) and make a new table
    > UserPrices
    > -------------
    > UserID
    > ProductID
    > Price
    >
    > Then, you just have to link the user, product, and userprices tables to
    > get
    > the appropriate product prices for each user.
    >
    > "Andy" <AndyjhughesNOSPAM@ntlworld.com> wrote in message
    > news:cvmq2p$kou$1@forums.macromedia.com...
    >> Thank you so much to you all. You've helped to make things look a little
    >> clearer.
    >> I'm glad that im at least on the right path :-)
    >>
    >> I have found one other question that has me stumped!
    >> Each UserID will have their own pricing sceme for the same products. I
    > can't
    >> get my head round how i could acheive this.
    >> Their would be too many prices for them to simply select one from a
    > dropdown
    >> list, so how could i allow each User (about 250) individual pricing for
    > the
    >> products?
    >>
    >> Hope this makes some sense and thanks very much to you all.
    >>
    >> Kind Regards
    >> Andy
    >>
    >>
    >> "Michael Fesser" <netizen@gmx.net> wrote in message
    >> news:mj9s115eg97ljbfke741mm9e29ubut8nro@4ax.com...
    >> > .oO(Andy)
    >> >
    >> >>I'm designing a simple database which has 13 fields
    >> >>I am tempted to use just one table but i know that this is NOT the way
    > to
    >> >>do
    >> >>things.
    >> >
    >> > Correct. Putting it all into a single table wastes a lot of resources
    >> > becaues of the redundant information and will cause many problems on
    >> > insert and update operations (called 'anomalies').
    >> >
    >> >>I'd like to learn a quick method of good database design.
    >> >
    >> > Good DB design can't be done between breakfast and dinner, it
    >> > definitely
    >> > takes some time. Search for some sites/tutorials about DB design,
    >> > especially about normalization/normal forms.
    >> >
    >> >>I have created three tables from my fields as below.
    >> >>Would this be the correct design?
    >> >
    >> > I would not say a DB design can be 'correct', but it can be good or
    >> > bad.
    >> > At least splitting it like you did below is the correct way.
    >> >
    >> >>How should i make the relationships and from which table/field to
    >> >>which?
    >> >
    >> > To connect two tables there has to be a kind of shared column(s) in
    >> > both
    >> > of them, holding the same values (read up on 'primary keys' and
    >> > 'foreign
    >> > keys'). In your case the products table would need a column categoryID,
    >> > which stores the ID of the category the product belongs to. This ID can
    >> > then be used to identify the associated record in the categories table.
    >> > Such a layout is called 1:m relationship (one-to-many): a product can
    >> > be
    >> > part of only one category, but each category can hold many products.
    >> >
    >> > Another and probably better option is to use a third table to connect
    >> > the products and categories table, something like
    >> >
    >> > table products
    >> > --------------
    >> > productID
    >> > title
    >> > description
    >> > ...
    >> >
    >> > table categories
    >> > ----------------
    >> > categoryID
    >> > title
    >> > description
    >> > ...
    >> >
    >> > table belongs
    >> > -------------
    >> > productID
    >> > categoryID
    >> >
    >> > This is called a m:n relationship (many-to-many). With this it's
    >> > possible to assign multiple categories to one product (and of course to
    >> > have multiple products in each category). The products and categories
    >> > tables use an ID as their primary key, the same IDs are used in the
    >> > third table as foreign keys (references). This table contains a record
    >> > for every combination of a product and a category. While such a layout
    >> > may look rather complicated, it's very flexible and efficient.
    >> >
    >> > HTH
    >> > Micha
    >> >
    >>
    >>
    >>
    >
    >
    >


    Andy Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139