I am hoping for a little clarification/education here. My understanding of
how foreign keys work is very minimal.

In using MySQL for the last several years as a backend to web apps I have
always managed relationships amongst the tables with auto increment primary
keys myself. 

I have a new project where I need to somehow automate some of that.
Traditionally I have just inserted the parent row into the parent table,
grab the PK and insert this into the child table with the data.

I am hoping that by using FK based relationships I can just do one massive
insert  into the parent table and include all related columns and somehow
magically all field and relational keys fall into place.

Example:
Parent table - People
Columns - person_id, firstname, lastname

Child table - Homes
Columns - home_id, person_id, address

Then I could do something like:

insert into people (firstname, lastname, address) values ('xxx','xxx',xxx');

And hopefully due to the FK relationship it would match the proper field and
insert the data into the matching table and auto populate the person_id in
the homes table with the corresponding parent row's PK (person_id)

Am I totally off base or is something like this possible?


Thanks

Steffan

---------------------------------------------------------------
T E L  6 0 2 . 7 9 3 . 0 0 1 4 | F A X  6 0 2 . 9 7 1 . 1 6 9 4
Steffan A. Cline  
[EMAIL PROTECTED]                             Phoenix, Az
http://www.ExecuChoice.net                                  USA
AIM : SteffanC          ICQ : 57234309
YAHOO : Steffan_Cline   MSN : [EMAIL PROTECTED]
GOOGLE: Steffan.Cline             Lasso Partner Alliance Member
---------------------------------------------------------------




-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to