many to one relationship

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default many to one relationship

    How do I set up the tables and relationship such that I
    can reflect the item desc. of all items in my shopping
    cart? I am having item1, item2,..., itemN in my shopping
    cart which all join to itemID in the items table. Since I
    have multiple items in the shopping cart how does sql know
    which item I am requesting
    James Guest

  2. Similar Questions and Discussions

    1. MySQL relationship
      After a migration from Access to MySQL V5, I have lost the Access relationship. I tried to recreate them into MySQL, through declaration of foreign...
    2. Relationship in MS Access
      In MS Access, there is an interface to draw the relationsip between tables. Do I really have to draw the relationship to obtain databse data?...
    3. URGENT BUSINESS RELATIONSHIP
      DEAR SIR, MY NAME IS MR.BEN IFEANYI, THE MANAGER CREDIT AND FOREIGN BILLS OF ECOBANK OF NIGERIA .I AM WRITING IN RESPECT OF A FOREIGN CUSTOMER...
    4. Breaking a relationship
      Any help will be appreciated- 1. Originally set up a combo box in a form referencing a look-up table. 2. Redesigned the look-up table and saved...
    5. threeway relationship?
      Ok, so I have been up since early this morning actually focusing on Filemaker, and the database I have been thinking about building since I got my...
  3. #2

    Default Re: many to one relationship

    SELECT
    b.ItemID
    , b.ItemDescription
    FROM
    Items AS b
    INNER JOIN
    Basket AS a
    ON
    a.ItemID = b.ItemID
    WHERE
    a.BasketID = <....>

    <....> is the BasketID that you have assigned to the particular user.

    Cheers
    Ken


    "James" <jtnchang@hotmail.com> wrote in message
    news:065601c3943c$fc992770$a101280a@phx.gbl...
    : How do I set up the tables and relationship such that I
    : can reflect the item desc. of all items in my shopping
    : cart? I am having item1, item2,..., itemN in my shopping
    : cart which all join to itemID in the items table. Since I
    : have multiple items in the shopping cart how does sql know
    : which item I am requesting


    Ken Schaefer Guest

  4. #3

    Default Re: many to one relationship

    Thanks Ken. So instead of itemID1, itemID2,... I would just have itemID
    and as long as long as I have my while not rs.eof loop it will get all
    the items that meet the criteria. so the problem with my tables design
    is that I designed the basket table with item1, qty1, item2, qty2,.... I
    should have just one item and one qty but in the form I would make
    provision for multiple pairs and do a while request("item")<> "" to
    retrieve the pair, one at a time. Thanks very much for your
    enlightenment.

    jc123

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    jc123 Guest

  5. #4

    Default Re: many to one relationship

    > the items that meet the criteria. so the problem with my tables design
    > is that I designed the basket table with item1, qty1, item2, qty2,...
    Yes! This is not very well designed at all. If I want to add 40 items to
    my cart, are you going to have to alter the table to accommodate me?
    item40, qty40, etc? *shudder*


    Aaron Bertrand - MVP Guest

  6. #5

    Default Re: many to one relationship

    I think what you really want is a many to many relationship.
    Three tables....

    Table1 is your items table which describes individual items
    Table2 is your shopping cart which would describe a cart
    Table3 is your cart details (the joining table) which would likely only have
    three columns - the unique cart id, the unique item id and the quantity of
    items.

    Ken's query implies Table 2

    "James" <jtnchang@hotmail.com> wrote in message
    news:065601c3943c$fc992770$a101280a@phx.gbl...
    > How do I set up the tables and relationship such that I
    > can reflect the item desc. of all items in my shopping
    > cart? I am having item1, item2,..., itemN in my shopping
    > cart which all join to itemID in the items table. Since I
    > have multiple items in the shopping cart how does sql know
    > which item I am requesting

    Tom B Guest

  7. #6

    Default Re: many to one relationship

    When the order is placed, you probably also want to store price, weight,
    shipping information etc. so that when users or administrators review orders
    from history, even AFTER prices have changed or container sizes have
    increased/decreased, they see their order as it was, not as it would be if
    they placed it today.




    "Tom B" <shuckle@hotmail.com> wrote in message
    news:#E2MTtLlDHA.1740@TK2MSFTNGP12.phx.gbl...
    > I think what you really want is a many to many relationship.
    > Three tables....
    >
    > Table1 is your items table which describes individual items
    > Table2 is your shopping cart which would describe a cart
    > Table3 is your cart details (the joining table) which would likely only
    have
    > three columns - the unique cart id, the unique item id and the quantity of
    > items.

    Aaron Bertrand - MVP Guest

  8. #7

    Default Re: many to one relationship

    A good point. One that's tripped me up before. If it can change in the
    future.....store it now.
    There's a good example here

    [url]http://www.aspfaq.com/cart/[/url]

    It only uses two tables(plus one for the customer), but still uses the
    many-to-many relationship for the cart.

    "Aaron Bertrand - MVP" <aaron@TRASHaspfaq.com> wrote in message
    news:O3WRZQMlDHA.2444@TK2MSFTNGP09.phx.gbl...
    > When the order is placed, you probably also want to store price, weight,
    > shipping information etc. so that when users or administrators review
    orders
    > from history, even AFTER prices have changed or container sizes have
    > increased/decreased, they see their order as it was, not as it would be if
    > they placed it today.
    >
    >
    >
    >
    > "Tom B" <shuckle@hotmail.com> wrote in message
    > news:#E2MTtLlDHA.1740@TK2MSFTNGP12.phx.gbl...
    > > I think what you really want is a many to many relationship.
    > > Three tables....
    > >
    > > Table1 is your items table which describes individual items
    > > Table2 is your shopping cart which would describe a cart
    > > Table3 is your cart details (the joining table) which would likely only
    > have
    > > three columns - the unique cart id, the unique item id and the quantity
    of
    > > items.
    >
    >

    Tom B 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