Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Re: Re: Yet Another Half Perl Half mySQL Question

by eejack (Hermit)
on Jul 06, 2001 at 23:15 UTC ( [id://94566]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Yet Another Half Perl Half mySQL Question
in thread Yet Another Half Perl Half mySQL Question

I would tend to agree with you, but you really only need the two tables if the assumption is a one to many relationship.

But assuming a many to many relationship your schema is nicer, and certainly if you expand the scope, having an id on both the ip address and name is a good thing (most probably a necessary thing).

One minor point though, you can still do reverse lookups on my schema:

$sql_statement = qq|select tbl_names.str_name from tbl_ipaddresses, tbl_names where tbl_ipaddresses.str_ipaddress = '201.2.23.2' and tbl_names.id_name = tbl_ipaddresses.id_name|; $sth = $dbh->prepare($sql_statement); $rv = $sth->execute; while ( ($str_name) = $sth->fetchrow_array ){ # do whatever }
But thanks for pointing out a nicer way of doing it than I did.

Thanks,

EEjack

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (6)
As of 2024-03-28 11:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found