I'm building a sort of login system for my website and I want to log user's activity in the database. The problem is with storing the IPs of the user each time.
I have the users table with all the user's details, such as username, pass etc. But if I'll add another column with the IPs, the only way to store it(that I am aware) is JSON kind of format(the TEXT one). So it would be something like:
username: theuser password: thepassword etc... IPs: { '27/04/2018 13:05': '127.0.0.1', '28/04/2018 16:28': '127.0.0.2', etc }
But...
1) Is it efficient to store IPs like that?
2) If yes, then how can I update each time the date and IP, so it won't erase the previous ones?
3) If instead of using the same table, I will create a new one, say "users_IPs", and then will store the user-id there, and then will use the same TEXT(JSON-like format) to store the IPs, would that be more efficient?
If you think there's a better way of dealing with this kind of thing, you're most welcome to share you thoughts.