On some websites I have seen two history of events: Payment History and View/Watched History.
I want to have both payment and viewing histories in my app, but I got stuck when I started thinking about the database schema.
As a basic example, the easiest way to do this for the view history would be:
- Have one table called
- Have these four columns, at least:
So when a user with an
ID of 80 visits a view with an
ID of 22, this should be added to the table.
user_id 80 views the View History view, it will loop through the
view_history table and displays only the rows that match the
user_id = 80.
This is the easiest way of doing this, but I'm afraid it is also the worst. Log tables tend to get big pretty quickly and I assume looping through this whole table wouldn't be ideal performance wise.
With that in mind, can you suggest the best approach to this?
Edit: I apologize if this wasn't the right place to post this question.