Thanks for all of the advice. I am learning, and want to learn the right way, and all the advice given will benefit me greatly in the long run. I wish there was an easier way to deal with relationships in MySql, but I am sure that will come along in time.
Mike > From: "Tracker 1" <[EMAIL PROTECTED]> > Date: Mon, 24 Jun 2002 01:57:17 -0700 > To: [EMAIL PROTECTED] > Subject: [PHP-DB] Re: Question > > you are thinking backwards.. > > drives 1-> computers > > tblComputers > iCompID As BigInt Primary Key Autonumber, > sCompName As VARCHAR(25) > ... > > tblDrives > iDriveID As BigInt Primary Key Autonumber, > iComputerID As BigInt Not Null, > Foreign Key fkDriveComputer (iCompID) References tblComputers(iCompID) > > note, you need to use InnoDB tables in mysql for foreign key references > to work properly, you should do it in your code anyway.. > > select * from tblComputers > for each rsComp.. > select * from drives where iComputerID = (rsComp.iCompID) > > there you go.. :) > > -- > ======================================================================= > Michael J. Ryan - tracker1[*at*]theroughnecks.com > Roughneck BBS: http://www.theroughnecks.net telnet://theroughnecks.net > ======================================================================= > Y!: aztracker1 - aim: azTracker1 - icq: 4935386 - msn: see email > One program for aim/icq/yahoo/msn/irc - http://www.trillian.cc/ > > > "Mike Tuller" <[EMAIL PROTECTED]> wrote in message > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... >> I am wanting to create a PHP frontend to a database that holds information >> about the computers that I take care of. I have a problem though when it >> comes to storing hard drive information. In most cases, the computers have >> one drive, but some have 2 or more, so I can't create the main database with >> fields like this. >> >> ComputerID >> HardDriveType >> HardDriveSize >> >> I know I will need to create a separate table to hold information about the >> drives, and connect them to the computer by attaching the primary key of the >> drives table to the Computer table. >> >> Computer Table >> >> ComputerID >> DriveID >> ------------------------ >> Drive Table >> >> DriveID >> HardDriveType >> HardDriveSize >> >> This is where I am unsure. If there is more than one drive, then this would >> be incomplete because it would only show one drive. What is the best way to >> make it so that all drives show for the computer, or am I doing this >> backwards? Should I tie the computer to the drive instead? >> >> Thanks, >> Mike >> > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php