Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2002
    Posts
    1

    Unanswered: Nested databases?

    Hi, I'm working on a site that lets students rate CS professors in my university. Since I'm new to MySQL, I'm having a little difficulty in implementing databases.

    What I basically want to do is to store the details of every professor and all the comments and ratings about them. I created a database that lets me store general information about each instructor, e.g. e-mail and web site. What I don't know is how to store students' comments. Every professor should have a lot of separate comments and ratings about them. Maintaining a separate database of comments for each professor makes little sense to me. The only thing I can think of is some sort of database where one field in every record is a database of comments and ratings. Is there any way to do this?

    I'm using PHP with MySQL. Please bear with my naivety.

  2. #2
    Join Date
    Jan 2003
    Posts
    5
    Sounds like you would benefit from looking at articles on "normalizing databases" or "database normalization" for starters. What you want to accomplish is done by linking two databases on a common key. This is needed anytime you find yourself wanting to add many entries for the same column/row combination (or cell). This is a "one-to-many" relationship from the standpoint of each professor. Your instinct is quite right as to how many comments relate to one professor. So you will make a separate student comments table and separate professors table. In the comments table one field will be the professor's ID number.
    Once you have the concept clearly in mind, you will then seek information on joins in a query to implement your MySql SQL statements. I recommend consulting "Web Database Applications with PHP & MySQL" (O'Reilly) for a thorough treatment, but you really don't need to buy a book for this application. Just plow on!

  3. #3
    Join Date
    Jan 2003
    Posts
    5

  4. #4
    Join Date
    Jan 2003
    Posts
    5
    Originally posted by rgbatson
    Sounds like you would benefit from looking at articles on "normalizing databases" or "database normalization" for starters. What you want to accomplish is done by linking two databases on a common key. This is needed anytime you find yourself wanting to add many entries for the same column/row combination (or cell). This is a "one-to-many" relationship from the standpoint of each professor. Your instinct is quite right as to how many comments relate to one professor. So you will make a separate student comments table and separate professors table. In the comments table one field will be the professor's ID number.
    Once you have the concept clearly in mind, you will then seek information on joins in a query to implement your MySql SQL statements. I recommend consulting "Web Database Applications with PHP & MySQL" (O'Reilly) for a thorough treatment, but you really don't need to buy a book for this application. Just plow on!
    Also see: http://www.devshed.com/Server_Side/M...l1/Normal1.pdf

Posting Permissions

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