Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 2 of 2 FirstFirst 12
Results 16 to 20 of 20

Thread: Phpmyadmin

  1. #16
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    cant i do it buy using a text field and seperate them by comma's ','s then explode the results?

  2. #17
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,634
    Thanks
    4
    Thanked 148 Times in 139 Posts
    items belong in their own row. As presented before, the article I linked to explains why you should not store a list in a column.

    The article explains how you can draw up a list of what everyone has, as well as easily compare the items you have to see how many of them I have.

    No loops necessary.

  3. #18
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    Code:
    Name 	Type 	Sell Value 	Total Sell Value
    Tank top [Info] [Send] 	Clothes 	$32 	$32
    Pair of trainers [Info] [Send] 	Clothes 	$35 	$35
    Jacket [Info] [Send] 	Clothes 	$40 	$40
    Personal computer [Info] [Send] [Turn on] 	Electronic 	$300 	$300
    Simple virus [Info] [Send] 	Virus 	$500 	$500
    thats how i want it to end up looking? do you think they use database normalization, as posted prior to this?
    i read over the post again and im still not sure how it works,
    so i create an extra table and each item has its own field?
    then i would need to make a list of people in that table which own that item?
    sorry i really am not trying to sound thick, this is pretty much my first real MYSQL experience
    /*edit*/ i already have a table which has all the items in with description, id, price, etc.. /*edit*/
    Last edited by rafiki; 03-26-2007 at 09:33 PM.

  4. #19
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Yes. Going back to your chicken and chips example, you'd have a "person" table and a "favoritefoods" table. Heck, let's make it a "favorites" table and add a column that describes what kind of favorite it is.

    So the person table has a unique key, let's call it person_id.

    The favorites table links to the person table by storing that person_id.

    Person table data
    person_id name
    --------------------
    10001 randy
    10002 mike

    Favorites table data
    person_id description type_code
    ----------------------------------------
    10001 chicken food
    10001 chips food
    10001 meatballs food
    10001 blue color
    10002 football sport
    10002 pizza food
    10002 liver and onions food

    Then you write a join query to connect the two tables.
    Code:
    SELECT p.name, f.description, f.type_code
    FROM person as p
    JOIN favorites as f
    ON p.person_id = f.person_id
    This is a very basic example. You'd probably want to create one more table that stores types of favorites, especially if there is more data you want to store that relates to a favorite, such as price, and then use a table to link the person table with the favorites table. The article Gue linked to in a previous post has more fancy examples of how you can query data from two tables set up like this.

  5. #20
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    so its like having a foriegn key? (thats how i was taught at college) that connects to database's/tables? kinda making sense, but the table i need isnt favourite foods, its just random items, but i see where u were going, thanks for showing me the light


 
Page 2 of 2 FirstFirst 12

Posting Permissions

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