in reply to newbie table structure

Google and altavista are not tables, they're columns in a single table. That'll make the rest of your stuff trivial.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Replies are listed 'Best First'.
Re^2: newbie table structure
by FitTrend (Pilgrim) on Jan 30, 2005 at 00:43 UTC
    Randal's method is better. There is less to management. I would change the date to a MySQL date field which will store information as YYYY-MM-DD.
    "CREATE TABLE IF NOT EXISTS visits ( id int auto_increment not null, searchengine char(48) NOT NULL, useragent char(32) NOT NULL, ip char(32) NOT NULL, date date NOT NULL, primary key (id) )");
    You may have to use some perl magic to format the date appropriately. Although this probably not the most efficient way to write this, it demonstrates my point :)
    (undef, undef, undef, $Day, $Month, $Year, undef, undef, undef) = loca +ltime(time); $Month++; $Year += 1900; $MySQLDate = "${Year}-${Month}-${Day}";

    By including the searchengine field and a little extra work, you can also create some great reports such as:

    - how many searchengine entries per day
    select searchengine, date, count(*) from visits group by searchengine, + date order by date desc
    - how many searchengine entries for a specific day
    select searchengine, date, count(*) from visits where date = '2004-01- +31' group by searchengine, date order by date desc
    - total number of searchengine entries
    select searchengine, count(*) from visits group by searchengine
    And other reports based on IP addresses, specific useragents, and so on... You could also pass that information to GD::Graph::Bar and create some nice looking bar graphs that management will like. Even get more crafty and email them routinely to people using MIME::Lite and a cron job. These search engine can be found CPAN.

    Marc Bilodeau
    www.marcbilodeau.com

Re^2: newbie table structure
by coldfingertips (Pilgrim) on Jan 29, 2005 at 17:45 UTC
    Oh. In that case I appologize for getting the terms all messed up but I hope people know what I meant.
        Oh. In that case, I should be saying I'm sorry for messing up the terms THIS time then. lol. :)
Re^2: newbie table structure
by JoePerlHacker (Initiate) on Jan 29, 2005 at 21:27 UTC
    It is not only a pleasure, but an honor to be posting near Randal L Schwartz!! I happen to agree with him. You need to read a bit more on working with mySQL and the Perl DBI. Too much to explain here in this forum. Best of luck, Joe
Re^2: newbie table structure
by JoePerlHacker (Initiate) on Jan 29, 2005 at 21:31 UTC
    It is a pleasure and an honor to be posting next to Randal L Schwartz!! I have to agree with him. Sounds like you may need to spend some more time with the Perl DBI and mySQL books. Best of luck! Joe