The stats system we built for one of our projects has a stats table which records every page view as a row of data. We run a daily script that produces a summary (for faster stats viewing) and inserts one row per "page" into a stats summary table.
The stats montly summary table thus has a pageid, year and month fields. Every day when we run the update, we delete that month's summary rows, then crunch the numbers and add them back. There should never be more than one row in the table with a combination of the three fields above...
Page 1 -- 12 -- 2008
Page 2 -- 12 -- 2008
Page 1 -- 11 -- 2008
Page 2 -- 11 -- 2008
Each of the three fields gets duplicated, but never should there be a duplicate combination of the three.
Is there a way to require this in MySQL (so it will error on insert) but NOT have it be the primary key?
Thanks!










Bookmarks