Hello all,

How do you people solve the problem of multi-table updates?

Consider the following scenario: 
You got a php-program that has, say, ten fields.
You got your database that has it's data normalized (as the
good database designers we all are *grin*) and split up over,
say, four tables.
Now, if you want to check that some of the info in the fields
are already there, how do you go about it?

A practical example.
I've got a database of our computers. The database contains
name (fqdn), ip-address, mac-address, network, what switch/hub it's
connected to, rough location (ie, floor), accurate location (ie. what
room) etc.

I've got a php-program with the above-mentioned fields. 
I've got a ip_name_tbl table, a location table, a ac_loc table
and a hub_switch_tbl. I wan't to check that the information entered
isn't already in the database tables, but I want to be able to add,
say, two ip-addresses for the servers etc.

The way I solve it now is i SELECT name and other that I want to be
unique and see if I get anything. If not, add. If it's there, don't.

Obviously there's a problem with my approach: For each computer
inserted, there's a minimum of four or five SELECTs and four or
five INSERTs. 

I'm positive some of you have similar problems. How do you go
about solving it?

Markus Lervik


Markus Lervik                         | A Microsoft Certified Systems 
Linux-administrator                   | Engineer is to computing what 
Vaasa City Library - Regional Library | a McDonalds Certified Food 
+358-6-325 3589 / +358-40-832 6709    | Specialist is to fine cuisine

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to