I'd suggest that you have functions to perform each search, returning an array of matches. Then, just do a quick join of all your keys that match the search. The real question is "How do you make optimal search functions?"

To get the fastest, most foolproof solution, you should normalize the database. Rather than having vehicle entries like this:
my %cars = ( 1001 => { make => "Chevrolet", model => "Camaro", year => 1972, price => 6000, }, ...
You should have this:
my %cars = ( 1002 => { make_id => 10, model_id => 27, year => 2001, price => 24000, }, ); my %makes = { 1 = "Chevrolet", 10 = "Acura", }; my %models = { 12 = "Camaro", 27 = "RSX", };
Then, your "make" and "model" search functions are doing fast, numerical comparisons, and not string matches. And you're guaranteed to have consistent spelling of Chevrolet! You never have to match /chev(y|rolet)/i!

You'll probably want other fields, like "description", "series", "miles", etc.

You'll also want things like "show_price" and "show_miles". If that 1972 Camaro has 217,000 miles, no one is gonna look at it at $6,000, even if it's puff! So, just don't show the price -- and get the customer in there to see how well it's been restored.

Other thoughts: Might Storable be a better way to go than DB_File, monks?

There's no way for you to go with MySQL, huh? :)

I've got just a *little* experience with exactly this stuff <dripping sarcasm> - 1 2. /msg me if you need more help.

In reply to Re: Question about properly laying out a database by joealba
in thread Question about properly laying out a database by Stamp_Guy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.