I want to store events in table with datetime and need to return the events count based on user request like hourly, daily, monthly etc.
so i am thinking of two designs
tbEvents
eventDate datetime, eventId int
tbEvents
year int, month int, day int, hour int, eventId int
Since I want to groupBy like (year)/(year, month)/(year, month, day) in different queries, I want a optimum table design. Please help me to choose.
a single datetime entry is almost certainly the right choice (unless you are on some obscure db)
you cn always parse that with built in sql functions at query time.