I want to log events from my client component and analyze them in google's BigQuery. My problem is that the events are of several different types (with potential for more types to be added in the future) - each event type has a different number and types of properties.
For example:
{"event":"action",
"properties":{"ts":1384441115,
"distinct_id":"5EB54670",
"action_type":"pause",
"time":"5"}}
{"event":"action",
"properties":{"ts":1384441115,
"distinct_id":"5EB54670",
"action_type":"resume",
"time":"15"}}
{"event":"section",
"properties":{"ts":1384441115,
"distinct_id":"5EB54670",
"section_name":"end",
"dl_speed":"0.5 Mbit/s",
"time":"25"}}
My question is - how do I handle this diversity in a tabular DB? My reason for choosing BigQuery is its ability to handle big data calculation and analysis of my logged events, but for that to happen I need to figure out the best practice to log these events.
I thought about 2 options:
1. have a large table that has columns for every property of every event type - in this case every row will contain empty fields.
2. have a separate table for each event type - this raises two issues - future events will call for new tables, and even worst - I loose ability to perform calculations over all events (seeing as all events share some properties like ts, distinct_id and time)
I'm pretty sure I am not inventing the wheel with my use-case, so I would love to hear about the best practices from you guys. Thanks!
Amit