Syntactic Confectionery Delight | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
First and foremost, do not confuse SQL as a language or database format. While it has the word "language" in its name, it's really a standard for obtaining, and futzing with data across many different development tools (languages) and database formats/Products (MySQL, Oracle, Sybase, PostGres, Excess, xBASE, Paradox, yadda, yadda, yadda).
SQL is a standard for manipulating and defining databases. It has two types of statements:
Each statement is aptly named and operates against an object that generally makes sense. A decent overview will help. (See below) In your case, you're looking for something along these lines:
This returns all records from the Catalog table that have Catalog ID's in the range specified by the $lovalue and $hivalue variables. (The specific syntax will depend greatly on the database format you choose. For example MySQL has slight syntax variations over Oracle and ODBC.) With most DBI drivers, this will give you an array of matched records, that you can then print very quickly using whatever approach you're most comfortable with. To gain the cross platform success you're looking for, you need to choose your database format with care. I recommend starting with mySQL, for though it doesn't completely offer the features of a complete client/remote server database format, it is cross platform, easy to install, and free. Should you eventually outgrow it, you should be able to convert your SQL to your new format with little to no trouble. Like chess, the basics of SQL are easy to learn. Those eight statements I listed earlier are (arguably) pretty much the heart of SQL itself. It gets a little harder when you start learning the extensions and features of your database format. For example, many remote database servers support stored procedures and triggers, which are (essentially) chunks of code run by the database server to validate (and respond to) your data values and what the users does with them. This can be quite daunting, but it can be very powerful. Learn it as you can. Personally, I wouldn't worry about mastering Linux before tackling SQL. Get the Cheetah book; it'll help a great deal. It goes into the basics, offers a decent SQL tutorial, and walks you through the process very carefully. Also, it provides a great reference to various DBI drivers, which will help you make the most informed decision regarding the file format. As far as the latest AM advice is concerned, she (assumed) was offering advice on how to similate the SELECT statement without using SQL. Assuming that you're storing your data in a hash, she suggested building a second hash that sorted all records in order of your desired sort order. This hash contains two values: the value you're sorting on as the key and a pointer (or reference) to the "real" database record in the original hash. (Note that if you have multiple matches to the same catalog number, the second hash element should be an array of references to each unique record.) That way, you can quickly determine which set of records you're after, simply by examining the keys you're dealing with. --fIn reply to Re: Re: An odd flat file database question
by footpad
|
|