I want to design a database for events and track a lot of statistic about the it.
Option 1
Create one table for Events
and put all my statistic column in it. Like number of male, number of female, number of unidentified gender, temperature that day, time it started, any fights, was the police called, and etc.
The query would be a very simple select * from events
Option 2
Create two tables, one for Events
and one for EventsAttributes
. In the Events
table I would store important stuff like id, event title, and start/end time.
In EventsAttributes
I would store all the event statistic and link them back to Events
with a eventId
foreign key.
The query would look like below. (attributeType == 1
would represent number of males)
select e.*,
(select ev.value from EventAttributes ev where ev.eventId = e.id and attributeType = 1) as NumberOfMale
from Events e
The query would be not be as straight forward as option 1, but I want to design it the right way and live with the messy query.
So which option is the right way to do it, and why (I'm not a database admin, but curious).
Thank you for your time.