Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Wisdom of data in hashes vs. SQL

by cmeyer (Pilgrim)
on Jun 13, 2005 at 19:11 UTC ( [id://466258]=note: print w/replies, xml ) Need Help??


in reply to Wisdom of data in hashes vs. SQL

I am a big fan of MLDBM for simple databases. I am not familiar with DBM::Deep; I'll have to give it a look. However, I prefer a relational database, once the data design gets very complicated. There's lots of functionallity in relational databases that can be leveraged against. (Aside: any English whizzes like to correct or corroborate my use of "leveraged" there?)

If your $db is a HoH type structure then it is easy to pull certain records from it with a little Perl:

# store some stuff in the "database": $db->{ record_1 } = { greeting => 'hello', perl => 'rules', etc => [ 42, 99 ] }; $db->{ some_other_record } = { greeting => 'Oi, gente', perl => 'r0x0rs', etc => [ 38, 45 ] }; # and so on # now find keys of all records that "rules" my @keys_of_records_that_rule = grep { $db->{ $_ }{ perl } eq 'rules' } keys %$db;

-Colin.

WHITEPAGES.COM | INC

Replies are listed 'Best First'.
Re^2: Wisdom of data in hashes vs. SQL
by biosysadmin (Deacon) on Jun 13, 2005 at 22:27 UTC

    Sticking information into a RDBMS is a good idea in my experience, here's some reasons:

    • It gives you a data model that's independent of your language and application, and potentially even RDBMS software. This can be very useful if you ever need to switch languages, which has been known to happen.
    • For projects that grow to be large, you can use an separate machine as your database server.
    • It's a solution that's well understood by people who develop software, which is a good thing if your code will ever be maintained and built upon by others.

    On the other hand, sometimes throwing things in a full-blown RDBMS is overkill, and Perl hashes are very very fast. So, like many things it depends on your situation. I really think that knowing both ways of storing data is extremely valuable, it's part of fully grokking TIMTOWDI. :)

    "There's lots of functionallity in relational databases that can be leveraged against. (Aside: any English whizzes like to correct or corroborate my use of 'leveraged' there?)"

    Don't end a sentence in a preposition without mentioning to the object of the preposition! To quote Winston Churchill, "This is the kind of impertinence up with which I shall not put." :)

    If I were to re-write your sentence, I would write somethng like this:

    Relational databases have a lot of functionality that can be leveraged to speed up development.

      I like the comment about giving you a data model independant of language and application. After all, even though, for example, I may prefer Perl over other languages, another person/department may prefer another language.

      And at the end of the day, it's the data that's most important.. so being able to share it is a big plus!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (8)
As of 2024-04-24 10:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found