Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.

On Databases

by beretboy (Chaplain)
on Aug 11, 2003 at 18:34 UTC ( [id://282975]=perlquestion: print w/replies, xml ) Need Help??

beretboy has asked for the wisdom of the Perl Monks concerning the following question:

For some time now I've been learning different programming languages, experimenting with them and writing code as a hobby. It has occured to me though, that I have been totally ignoring databases. A lot of you use perl almost entirely for database work, so I thought it fit to ask here. What do you like as far as databases? More importantly, do you know of any good tutorials for learning to use databases with perl (MySQL specifically)?

"Sanity is the playground of the unimaginative" -Unknown

Replies are listed 'Best First'.
Re: On Databases
by cchampion (Curate) on Aug 11, 2003 at 18:57 UTC
Re: On Databases
by Juerd (Abbot) on Aug 11, 2003 at 18:57 UTC

    I like DBD::SQLite very much. It's extremely easy to install, and when you move a project over to another box, you don't need to copy the database separately. It doesn't work with a server, but that is okay for what I do with it. SQLite is fast and feature-rich and worth checking out.

    Depending on the application, you may find Class::DBI very useful. Perhaps you want to write the queries yourself. In that case, have a look at DBIx::Simple. If you need extreme power or extreme speed, learn how to use DBI directly.

    Do read The fine art of database programming and Before asking a database related question ... by gmax.

    As usual, don't forget to use strict and small scopes. Database modules bite less if you let them destroy objects when they're no longer needed.

    Juerd # { site => '', plp_site => '', do_not_use => 'spamtrap' }

Re: On Databases
by Zaxo (Archbishop) on Aug 11, 2003 at 20:00 UTC

    There are two sides to learning database programming.

    One side concerns database design. Google for database normal form for some of the many treatments of making a db maintainable, efficient, and no bigger than necessary.

    The other side is learning SQL. It is an oddity of a language to many. It has a strong component of functional programming, but without any of the elegance.

    The third half, of course, is to learn That may as well be the first half ;-)

    After Compline,

Re: On Databases
by naChoZ (Curate) on Aug 11, 2003 at 19:10 UTC
    Here's some reading from the Tutorials section.

    Reading from a database
    The fine art of database programming

    It's a pretty broad question though. I'm sure the number of books written on the subject numbers in the hundreds. You'll get some better answers, but personally, I use them because it just makes it so darn easy to work with large amounts of data. Not only that, but you can relate different sets of data together. Make it look the way want when you output it. Massage the data however you want. Plus most database engines can be made to do quite a bit of work for you, as opposed to having to write the code yourself. For a simple example, if you had a database of, say, students and you wanted to know how many students you had in the database. Instead of having to script a counter and cycle through the database, just a single sql query will give you the results: select count(*) from students_db.

    Or, like one of my own hobby projects that I've fiddled with, a restaurant database. A database engine makes it very very easy to display a listing of, say, Italian restaurants. Then make it so that clicking on one of the entries displays the address and phone number.

    There are many other advantages as well. Platform independence, it doesn't (necessarily) matter from what platform you're accessing the database engine. IIRC, ebay uses Microsoft webservers accessing an oracle database installed on a Sun 15K. Speed is another issue. Database engines are designed to do this stuff, so the more work you can offload from your script onto the database, generally speaking, the faster you can make your application. This is a major area where one database engine can outshine another, by how much of the work that it can do *for* you.

    "I just read perlman:perlboot," said Tom, objectively.

Re: On Databases
by hardburn (Abbot) on Aug 11, 2003 at 19:02 UTC

    I recommend staying away from MySQL, unless you're already stuck with it. It might be fast, but it also ignores large swaths of modern database theory. Specifically, it doesn't do referential integrity, implements the bare-minimum requirements to be relational, and its transaction support is a joke. Those three things are hit within the first few chapters of any good database book.

    Try PostgreSQL instead. It implements everything in the above list, plus a whole lot of advanced options that I always miss whenever I'm forced to use MySQL.

    I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
    -- Schemer

    Note: All code is untested, unless otherwise stated

Re: On Databases
by artist (Parson) on Aug 11, 2003 at 19:02 UTC
Re: On Databases
by Ryszard (Priest) on Aug 12, 2003 at 13:44 UTC
    To add to an already complete list, I use postgres because of the integrity, transactions, and its level of sql92 compliance.

    I use it to store a parsed iptables logile, my mp3 collection, addressbook etc etc.

    I back it up each night, and can restore it in a glance if i do something stupid.. I've not had one failure with it, and with the DBI, its just "That Easy (tm)"

Re: On Databases
by jdtoronto (Prior) on Aug 11, 2003 at 21:25 UTC

    You could look for "MySQL and Perl for the WEB" - DuBois, and "MySQL Cookbook" - also by DuBois


Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://282975]
Approved by broquaint
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-21 20:11 GMT
Find Nodes?
    Voting Booth?

    No recent polls found