#1
  1. No Profile Picture
    Robert_J_Sherman
    Guest
    Devshed Newbie (0 - 499 posts)
    My Question is more of a "feasability" question than anything else.

    I am planning on writing a "customer ordering system" and in an effort to conserve database space, I was thinking of setting the "ordered" item_id's into a single column, comma separated.

    Now, the explode() function gives me a method of "separating" data (in this case) by the comma.

    Naturally this would give me an "Array" to loop through and so on.

    Is this the right idea?

    or would "you" suggest a different approach?

    ------------------
    SnR Graphics,
    Low Cost Hosting and Web Development.
  2. #2
  3. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,646
    Rep Power
    4492
    I did a shopping cart like this and it worked well. You can easily pass the whole array to functions to determine costs and print out contents of shopping carts, etc...

    ---John Holmes
  4. #3
  5. No Profile Picture
    Robert_J_Sherman
    Guest
    Devshed Newbie (0 - 499 posts)
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by SepodatiCreations:
    I did a shopping cart like this and it worked well. You can easily pass the whole array to functions to determine costs and print out contents of shopping carts, etc...

    ---John Holmes
    [/quote]

    Thanks for the feedback, figured it would work, and using explode was the way to get
    the array.


    ------------------
    SnR Graphics,
    Low Cost Hosting and Web Development.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    63
    Rep Power
    15
    It will work fine but I have had problems with "non-normalized" database structures. Mainly, if you ever want to run any reports based on item numbers, it's a true pain. Basically, advanced sql queries become a problem. I'd recommend a detail table, where there are multiple item numbers in a listing that stem from a master record.

    Example

    Main Table: order_mstr (with the customer number order number, dates, totals, and taxes.

    Child Table: order_detail (with the order number, item number, quantity, price, extended_price)

    Obviously, if you wanted to see how many of item X you sold within a certain date period, it would be much easier to run the query with this type of database structure.

    ------------------
    ----------------------
    Ulysses J Ludwig
    Consultant
    Ujludwig@yahoo.com
    213.948.8278
  8. #5
  9. No Profile Picture
    Robert_J_Sherman
    Guest
    Devshed Newbie (0 - 499 posts)
    Glad you pointed that out.. hadn't thought
    about a report ability of "items" sold, etc.

    Was really just trying to think of the best approach to carry the purchased items by a single customer.

    Of course, a sales table would be a decent approach to this. Where sales are recorded for reporting purposes.

    And in the items table an "inventory" column for items on-hand, adjusting the quantity by purchase.



    ------------------
    SnR Graphics,
    Low Cost Hosting and Web Development.

Similar Threads

  1. Replies: 2
    Last Post: August 18th, 2004, 10:45 PM
  2. Replies: 5
    Last Post: February 3rd, 2004, 01:59 PM
  3. Help using a database and php to update a scores page.
    By deathsythe in forum PHP Development
    Replies: 0
    Last Post: February 2nd, 2004, 02:48 PM
  4. Sorting PHP Content into 3 Even HTML Columns?
    By metal2000 in forum PHP Development
    Replies: 5
    Last Post: January 28th, 2004, 10:53 PM
  5. PHP & Database Problems
    By flipsided in forum PHP Development
    Replies: 2
    Last Post: January 25th, 2004, 05:58 PM

IMN logo majestic logo threadwatch logo seochat tools logo