Avatar of Member_2_8034623
Member_2_8034623
 asked on

mysql creating a user log

Hi

I want to create a detailed user log.

currently, I have created a table that stores the Id, date, userId, table name and table id.

if I run a query it works fine to display basic details. however, if I want to display the contents of the table name and Id I inserted I run into a crappy situation where I would need to create a procedure. the procedure would run the basic select and dynamically join the other table based on the table name and table id I inserted into the log database.

another problem is that not at tables are the same therefore this method would only partially work anyways.

the table names field is manually added when adding the log data set

how can I accomplish a nice log?
MySQL Server

Avatar of undefined
Last Comment
Julian Hansen

8/22/2022 - Mon
David Johnson, CD

What do you want to log.. The normal answer is everything but this just duplicates a lot of data that is already present somewhere else.
user logs in to application
user views
user crud data
user crud data
user crud data
user reports data
user disconnects.
Member_2_8034623

ASKER
Hi

I am concerned with user crud data

I realize even keeping a log is a duplication of some data points in the larger dataset held within the individual tables. However, to accomplish a simple select on the log table i would need to create multiple unions creating an ever-expanding select statement
Julian Hansen

Do you want to record that the user changed something or do you want to record what the user actually changed?

How do you want to use the data - once you have data in your log - how do you envisage consuming the data - what sort of extracts will you want to run?
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Member_2_8034623

ASKER
Hi,

I want to give a user an accurate listing of creation and updates a user has performed within the service. I would display these via html with links to the corresponding dataset.

Eventually, i would want it to display the version levels on an update (similar to what WordPress does with their page versions)

The overarching mechanism is to have an audit trail of everything the user is doing.

I am not concerned with reading or deletion(The user doesn't actually delete anything in the database)
ASKER CERTIFIED SOLUTION
Julian Hansen

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Member_2_8034623

ASKER
A json encoded string makes a wack of sense and allows for some serious flexibility. i didnt even think of that!

Thanks
Julian Hansen

You are welcome.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.