I am creating an application in vb.net in which many users can add, update, and modify data stored in sql, but one user at a time. Users have to login to the application and then they can start their work. I want to know how I can monitor their work after they log out, like which user updated the record and at which time. Please help me with the logic and how I can make this application for monitor user task.
I already created the database in mysql in which I can store user log in and log out time now I want to store their work.
For a very basic solution, create a new table that's used exclusively for logging. Each action creates an entry (row) in that table that links their user account with a description of the action.
CREATE TABLE UserActivity
(
ActivityId INT NOT AUTO_INCREMENT PRIMARY KEY,
UserId INT NOT NULL,
Message VARCHAR(255),
Timestamp TIMESTAMP
);
If you want more detail, you could create the table to accept foreign keys to the actual entries in the table(s) that was/were changed. But I would start simple with a VARCHAR
concise description, eg
INSERT INTO UserActivity (UserId, Message)
VALUES (123, 'Updated user 456');
If you're not looking for a complete history and are just looking for who last touched it, you can add two columns to each table: LastUpdated & LastUser, then update those two columns when anything is altered. (As @MarkHall suggested in a comment)
ALTER TABLE mytable
ADD COLUMN last_updated TIMESTAMP
ADD COLUMN last_user INT;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.