Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Inserting values into MS Access sub tables

by sedhed (Scribe)
on Jul 08, 2002 at 18:23 UTC ( [id://180258]=note: print w/replies, xml ) Need Help??


in reply to Inserting values into MS Access sub tables

Please correct me if I'm misunderstanding your question. Also, I'm not familiar with Win32::ODBC, I use DBI. But this is more of a database design thing, not database or connection specific.

While many database systems do have the functionality to specify tables' relationships, one relies on that functionality only to enforce referential integrity on a DBMS level. Your code still needs to account for those same relationships.

To that end, one generally places a corresponding key field in each table, so that the tables can be JOINed in statements. So your servers_tbl already has an key field, which is a unique primary key. So far so good. Put a corresponding field in your drives table, called 'server_id' or something, and use that field to join on.

Your basic data would look something like so....

servers_tbl:                drives_tbl:
_ID____NAME_____            _LETTER__SERVERID____FOO___
1     SomeServer            C        2          blahblah   
2     OtherServer           D        2          ahblahbla
956   YetAnotherServer      C        956        foobar
And a select to get all of OtherServer's drives might look something like:
SELECT drives_tbl.LETTER, drives_tbl.FOO, servers_tbl.NAME FROM servers_tbl LEFT OUTER JOIN drives_tbl on servers_tbl.ID = drives_tbl.SERVERID WHERE servers_tbl.NAME = "OtherServer"
Hope this helps.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://180258]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-03-29 14:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found