Jump to content

Recommended Posts

I'm designing an application that monitors page traffic. This application collects the user's ip, checks in the database whether that ip has seen this page before. If the ip has, it adds one to the IP's view count. If it hasn't, it adds the ip to the database. My table looks like this:

 

[pre]IP | HITS

---------

  |

  |[/pre]

 

So basically, this is how the data is collected. My question is this:

 

If I am monitoring several pages, do I just add a third column called 'page', and have a HUGE table containing possibly thousands of rows, OR, do I have a table like this for every page?

Link to comment
https://forums.phpfreaks.com/topic/96368-lots-of-tables-or-loads-of-rows/
Share on other sites

I'd suggest adding a third column in the existing table, called something like 'pageID'.

 

Then add a second table that contains two fields, 'pageID' and 'pageName'. The pageIDs would then be relate in a basic one-to-many relationship.

 

This way you can change a page name (if a change is required) in only one row in the second table, rather than having to change it in each row in the main table.

Yeah, I was stating the obvious a little. Sorry.

 

The other benifit of the method above is that you can much more easily add new pages at a later date, by simply adding a new row to the pages table (rather than having to make a whole new table the other way).

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.