Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 782115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:20:08+00:00 2026-05-14T20:20:08+00:00

need help with logging all activities on a site as well as database changes

  • 0

need help with logging all activities on a site as well as database changes.

requirements:

  • should be in database
  • should be easily searchable by initiator (user name / session id), event (activity type) and event parameters

i can think of a database design but either it involves a lot of tables (one per event) so i can log each of the parameters of an event in a separate field OR it involves one table with generic fields (7 int numeric and 7 text types) and log everything in one table with event type field determining what parameter got written where (and hoping that i don’t need more than 7 fields of a certain type, or 8 or 9 or whatever number i choose)…

example of entries (the usual things):

[username] login failed @datetime
[username] login successful @datetime
[username] changed password @datetime, estimated security of password [low/ok/high/perfect]  @datetime
[username] clicked result [result number] [result id] after searching for [search string] and got [number of results] @datetime
[username] clicked result [result number] [result id] after searching for [search string] and got [number of results]  @datetime
[username] changed profile name from [old name] to [new name]  @datetime
[username] verified name with  [credit card type] credit card  @datetime
datbase table [table name] purged of old entries @datetime via automated process

etc…

so anyone dealt with this before? any best practices / links you can share?

i’ve seen it done with the generic solution mentioned above, but somehow that goes against what i learned from database design, but as you can see the sheer number of events that need to be trackable (each user will be able to see this info) is giving me headaches, BUT i do LOVE the one event per table solution more than the generic one.

any thoughts?

edit: also, is there maybe an authoritative list of such (likely) events somewhere?

thnx

stack overflow says: the question you’re asking appears subjective and is likely to be closed.
my answer: probably is subjective, but it is directly related to my issue i have with designing a database / writing my code, so i’d welcome any help. also i tried narrowing down the ideas to 2 so hopefully one of these will prevail, unless there already is an established solution for these kinds of things.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T20:20:08+00:00Added an answer on May 14, 2026 at 8:20 pm
    1. Logging database changes as far as inserts/deletes/updates, as far as best practices go, is usually done by a trigger on the main table writing entries into a audit table (one audit table per real table, with identical columsn + when/what/who columns).

    2. The list of events as a generic list doesn’t exist. It’s really a function of your application/framework/environment/business needs. As far as best practices, it’s a good idea to decide if your event type list is 100% flat, a 2-level hierarchy (type/subtype – this is usually the best approach) or an N-level hierarchy (much harder/less efficient to implement but incredibly flexible and offers very nice possibilities for proper enterprise event management – I had participated in implementation of all 3 schemes, so I speak from practice BTW).

    3. You don’t need 7 generic int fields in 1 table to store event details. Instead go for tag-value-pair table:

      EVENT_TYPES: (event_type, event_subtype, description, subtype_attr1, ...)
      EVENTS: (event_id, event_type, event_subtype, timestamp, attrib1, ...)
      EVENT_DETAILS: (event_id, tag, int_value, varchar_value, float_value).
      

      EVENT_DETAILS can be normalized into EVENT_DETAILS_INT, EVENT_DETAILS_VARCHAR, EVENT_DETAILS_FLOAT, … if you wish but not really required.

      attrib1-atttribN in EVENTS table are generic attributes that apply to all/most events, such as userid, hostname, pid, etc…

      EVENT_TYPES is a table describing assorted event types/subtypes.

      Depending on how you decided bullet point #2, this table may store flat list of types, a list of type/subtype mappings as in my example, or a hierarchy of parent type/child type (you will need 2 tables for that, one for parent/child mapping of types and one for type attributes of each type).

      You may want to have another auxiliary table EVENT_TYPE_ATTRIBUTES mapping event types to valid tags for EVENT_DETAILS.


    EXAMPLE:

    event: [username] clicked result [result number] [result id] after searching for [search string] and got [number of results] @datetime

    This would result in data similar to this (not actual SQL syntax, sue me :):

    EVENT_TYPES: (USER_ACTION, USER_CLICK, "User clicked something")
    EVENTS: (12345, "USER_ACTION","USER_CLICK", @datetime, "[username]", 
             "app_name", "pid"...) 
    EVENT_DETAILS: several rows:
     (12345, "result_number", 33, NULL, NULL) // Or go into EVENT_DETAILS_INT without NULLs? 
     (12345, "result_id", 919292, NULL, NULL)  
     (12345, "search_string", NULL, "how do I log events in DB", NULL)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 434k
  • Answers 434k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer At the head: <head> ... <script type="text/javascript"> var disabledConfirm_exit=false; </script>… May 15, 2026 at 3:18 pm
  • Editorial Team
    Editorial Team added an answer This is going to depend a great deal on what… May 15, 2026 at 3:18 pm
  • Editorial Team
    Editorial Team added an answer request.Form(stationIdea.UniqueID) The UniqueID property will return the id you are… May 15, 2026 at 3:18 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.