Hello, such a theoretical question
There are a huge number of logs of different types, the number of parameters is different for different types, the parameters themselves are also different
Tell me what to do right? Create a separate table for each type and use the union when receiving logs? Or stored in one table, leaving some parameters empty, depending on the type? Or make a table like
time p1 p2 p3 p4 p5 p6
Thank you very much in advance!

  • There are a lot of types and it is supposed to add them, the main user has entered time name The user has left time name The user has entered the command time name command Event number time event number There is much in common, but in one table without empty rows in any way ( - splite

2 answers 2

And why not make such a structure

1) Table Logs

  • Id
  • Time
  • Eventid

2) EventTypes table

  • Id
  • EventName (Event Name)

3) Table LogEvents

  • Id
  • LogId (log id)
  • EventParamId (parameter id)
  • Value

4) Table Parameters

  • Id
  • ParameterName
  • ParameterType

With such a structure, it makes no difference how many parameters the event has, how many types of events. If something is not clear, I can clarify.

  • A good idea! But it scares the complexity of requests, for example, I need to get logs with the Join type, where the value of the Name parameter is unique ...! With such a structure, there will be something beyond for me = ( - splite
  • 2
    Without such a structure, everything will be much worse. In Join, there's really nothing beyond the limit. - Sharp - eyed

Empty lines in the database must be avoided. I would make different tables for different logs, with a different set of fields, and would not dazzle the parameters in one field. You can assign indexes to these fields and make a selection, form data output in any way.

Here you need to see an example of data for different types of logs to answer more accurately and with an example.

ZY Tables and columns should be called clear names, and not p1, p2, etc.