Re: Re: Question
| From: | Mike Tuller | Date: | Wed, 26 Jun 2002 19:34:14 +0000 |
| Subject: | Re: Re: Question | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-20139@lists.php.net to get a copy of this message | ||
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" <tracker1@theroughnecks.net>
> Date: Mon, 24 Jun 2002 01:57:17 -0700
> To: php-db@lists.php.net
> 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" <mtuller@ce.anoka.k12.mn.us> wrote in message
> news:B93B72DF.10471%mtuller@ce.anoka.k12.mn.us...
>> 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
>