Are you adding a row per click?

I have just done the same and my table looks like this...
===========================================================
CREATE DATABASE marketing;

CREATE TABLE bsafeLinks
  (date DATE NOT NULL,
   clicks INT(255) NOT NULL);

ALTER TABLE bsafeLinks
  ADD PRIMARY KEY (date);
...................................
I basically have one row per day for the site I want to monitor. Every time
someone clicks I add 1 to clicks like this..
===============================
UPDATE bsafelinks
   
  SET   clicks = clicks + 1
             
  WHERE date = CURDATE()
...................................
I have some other code which creates the record if it does not exist...
====================================
insert into bsafelinks (date,clicks)
  values (CURDATE(),'0')
.....................................
And this does the test to see if the date record exists...
=====================================
select date, clicks from bsafelinks
                where date = DATE
.....................................
If you want hourly stats - add hour in after "date" and have as part of the
primary key.

Hope this helps.

Kevin


-----Original Message-----
From: svens [mailto:[EMAIL PROTECTED]]
Sent: 29 October 2002 12:52
To: [EMAIL PROTECTED]
Subject: jus a question about tables


So I have question.

is it ok if I put all data in one table by days (by date)
in resul I will have lot of rows

day 20021025 - 45000   rows
day 20021026 - 23445   rows
day 20021027 - 389023 rows
day 20021028 - 78632   rows
total = 536100 rows of data
I count web page hits and hosts by hourly rotate and date
(and one month will be woosh tons of data millions of rows)

all this data is in one table
so is it ok?

and when I need to get some statistics data 
then I query by date and name and ip  - and so on ?

or I need to seperate or move each day in some history table
and active table will hold only active day of data
?

for me is better to keep all data in one table of course
but who knows how to do better ?
if there is way to do better of course :)






---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to