SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question I don't know how to do this

    Okay, I've been playing around with PHP and MySQL for about half a year now. But now I've hit a roadblock What I want to do seems like there should be an easy way to do it, but I can't think of anything and I'm sure it's probably used by many databases. Here's an example of what I want:

    Let's say I wanted a database that has rooms of a house and the things that you can find in them. I want to be able to view a page for each room that contains a description of the room and a list of things in it. I also want to be able to view a page for each "item", a description, and a list of where it can be found. In a kitchen, let's say you can find a sink, towels, and silverware. In the bathroom you can find a sink, towels, and a bathtub. It would seem okay to build a table called Rooms and a Table called Items and have each room/item be a different row. However, what if a room has 50 things in it? Or if a single item can be found in 50 different rooms? I don't want my Rooms table to have a field called "Item1", "Item2" ... "Item49", "Item50". That just seems a little ridiculous.

    If anyone has an idea of how to do something like this, please post a reply. Thanks

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,274
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    here's a tutorial that will help you --
    http://www.utexas.edu/its/windows/da.../datamodeling/

    you're looking for a many-to-many relationship between rooms and items
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wow, I found the answers to my problem through all of that. Thanks a ton r937!


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
  •