I need to store page view for specific products by week, day and year. I thought about using the following tables:
Weekly
List item
id
product_id
week_number
year
total_page_views (counter)
Daily
product_id
total_page_views
[for the day I won't keep archive data and yearly will be calculated based on the weekly table]
My question is actually about the week numerical value. I am wondering which week number I should use, I've read that ISO 8601 is one option and using .NET DataTime function to get the week is another one. I need your help to know which one should I use and whether there is a better way to optimize the table.
At the end, I want to show the top viewed products for the previous week, this week, previous year, etc.
I target my app towards the US and Europe crowd, where the week start at Monday. I'm developing my application in C#/ASP.NET/MySQL/Entity Framework. THANKS.
Related
I have a data table that has a column for the fiscal quarter, a column for the net revenue made for row X's sale, and a column for the type of sale it was.
I want to use a forecasting method in R (was planning to use ARIMA, but am open to options) to predict future fiscal quarter net revenue per type of sale. For example, if the two types of sale are service and good, I want to create a model to predict future revenue for service and a model for good's future net revenue.
How would I approach this code and are there any websites you'd recommend I reference. Thank you in advance!
The websites I have found so far reference if every timestamp (i.e. every fiscal quarter) has only one row. But, my data table shows how i.e. quarter 1 can have 10 different sales and 5 can be labelled service and 5 are good.
I'm using Decibel on Wordpress to enter concert dates and times for a music festival. There are 5-7 concerts every day.
I want to sort the concerts with date and time, from earliest in the day to latest?
Right now, I can't figure out how the list is organized -- not alphabetically, not by publish date. I'm using no code other than the basic [wolf_tour_dates].
Thanks for the help,
A.
I am about to start creating a dimensional date table for a Data Warehouse project using SQl Server 2012.
On of the first user comments is that....
'Different customers will have a different first day of week, so not always a Monday'.
How would I accomodate for potentially 7 different start of week days in a single dim table or should i simply calculate it the conventional way on the fly on a per customer basis in a fact table and not use the dim date table?
Option 1. Calculate it on the fly using built in date match functions. SQL Server defaults to Sunday as the first day of the week.
Option 2. Create an additional column in your table for each day of the week indicating its day number of the week. For example column TuesdayFirst would have a 1 for every Tuesday and a 2 for each Wednesday.
Option 3. (Best) Create a view on your date dimension that calculates the additional columns for each day. Any of the columns that are not needed in the select will be ignored and not calculated. This gives the benefits of the persistent columns and the consistent calculation method, but does have some processing overhead versus pre-calculating.
If you choose option 3, do not use a CASE statement to calculate it. You must do it strictly with date math in order for it to perform decently when aggregating.
I've been thinking about how I can store counts of big nodes in my database and be able to compare those counts;
for example:
today vs the same day of past week
This month vs last month
This hour vs this hour yesterday
This hour vs this hour last week on the same day
So I came up with this:
The problem is: nested nested nested.
I do not want to get the whole data if I need only the year data.
My question: What would be the right structure for my use case?
You can keep YYYY, YYYY_MM, YYYY_MM_DD and YYYY_MM_DD_HH formatted nodes. That would be less expensive to retrieve data.
In reading this blog, this reference, and reviewing the answer to this question, I'm confused as to how one can represent distinct days in a timeline tree. In both cases they show a limited number of days on the example database and my thought is that this model cannot hold if you wanted to model an entire year or an unbounded temporal calendar period.
I am reading these examples such that the 'day' nodes are merely just the number of the day '1', '2', .. '31'. As every month has a day labeled '1', '2', etc, how do you traverse the path when you connect all days to months?
For example, in the attached modified drawing, month 12 and month 1 BOTH have days 1, 2 and 31 in them. When I look at event 2, how do I know if this took place on 12/31 or 1/31? I'd like to model all days for all months and using the template (as I understand it) creates ambiguous paths on the graph that do not allow for discrete temporal queries.
Or should a 'days' entity be a more unique number that represents the number of the day for that YEAR where the attribute for that number is the number of the day in the month?
As it stands I do not understand how you can create a complete timeline tree for an entire year as it is modeled in the above links.
The modified drawing shares the day nodes between months and that's why it's difficult to know whether event 2 took place on 12/31/2010 or 1/1/2011
The timetree for a single year, with a resolution of Day, will have 365/366 day nodes. So the Day node with value 31 is not shared by both January and December, but January and December have their own Day 31 nodes. In other words a day node relates to exactly one month, and a month node relates to exactly one year.
Then you can follow the path from the event back up to the root without having it diverge at month.
Peter's blog post referenced above shows the crossing of December into January but does not share the Day node 31- you can see that he's able to answer all your queries above.
To create the timeline, GraphAware has a module that maintains the timeline for you and helps you attach events as well- http://graphaware.com/neo4j/2014/08/20/graphaware-neo4j-timetree.html
Disclaimer: I work at GraphAware