SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Apr 2003
    Location
    canada
    Posts
    158
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Best practice question in the event a user selects multiple itmes from a category lis

    Hello,

    I wrote a small script that basically displays 20 to 30 categories on a page which a user has the option toeither select one or multiple items from the list. For the sack of argument the user selected the following items from the list:

    Table-> tbl_category : ‘Green car’, ‘truck’, ‘Van’, ‘minivan’,’ laptop’, ‘iPhone’, ‘great value mixed nuts 80% peanuts’, ‘cup’

    Tables I have:
    Table-> tbl_user
    Table-> tbl_category

    What is the best practice in terms of saving the multiple selection:

    1.Do I create a field in tbl_user and save the selection or selections into that one field?
    2. Create a separate tbl_saveCategoreySelection and save them as individual records and link it to tbl_user?


    At the same time the saved category list will need to be searchable.

    Any help you can provide would be greatly appreciated.
    Thanks

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,341
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    option 2
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Zealot
    Join Date
    Apr 2003
    Location
    canada
    Posts
    158
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    option 2
    would going with option number 2 would create a lot of repetitive entries. yes for different users but the table still would hlod repetitive info.

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,341
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by robin01 View Post
    would going with option number 2 would create a lot of repetitive entries. yes for different users but the table still would hlod repetitive info.
    don't worry about it

    imagine a table containing people's addresses -- there's a column for country, right? and many people would have 'CA' or 'US' as their country, right? is this repetitive? i suppose, but there's no way you'd want to try to avoid this

    same with your user categories... sure, multiple users might select the same category, but there's no way you'd want to try to avoid this
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


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
  •