Very easy NodeJs Task - Save data to mySql Database
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

Looking for nodeJs developer experienced in using mySQL from nodeJs for simple task. Long term opportunity

Summary: Current NodeJs app collects data every 10 seconds and displays it in browser.
Instead of displaying it in browser, I want to store the data in the mysql database.

Current app source: Click Here

Live demo: Click Here

Details: App counts the amount of tweets that contain a specific CashTag (e.g: "AAPL") during an interval of time.

Every 10 seconds the data is updated, displayed graphically, as an array at the bottom fo the screen.

We want to save the data that is on the array into the mySql database.

We will have three tables:

1) Watchlist table will contain the CashTags that we want to track. E.g: cash_tag = "AAPL".
Only items with active==TRUE shall be tracked.

TABLE watchList

INT AUTO INCREMENT symbol_id

VARCHAR(7) cash_tag

BOOL active

2) History table will contain records of historic values tracked

TABLE history

INT AUTOINCREMENT history_id

DATETIME when_it_happend

INT symbol_id # Remote key to item on table "watchlist"

INT number_of_twitts # Number of new twitts that occured. (Values that you see on the screen)

Populate this table by simply storing the data that is fetched every 10 seconds.

3) Diff table will contain incremental difference between records of historic values tracked

TABLE history_diff

DATETIME when_it_happend

INT symbol # Remote key to item on table "watchlist"

INT diff

In addition to populating previous table, you will also populate the history_diff table, inserting one record for every new data.

How will diff value will be calculated? Very simple formula:

Get the lastest value for that cashtag

$oldValue = mySQL[ SELECT number_of_twitts FROM history WHERE symbol = *$recentSymbolBeingAdded* ORDER BY when_it_happened DESC LIMIT 1 ]

Get current value and substract old value

$diff = $number_of_twitts /* current value*/ - $oldValue;

Store this value on the database. If $oldValue is missing because there are no previous records, use 0.

In other words, for every new set of data, you will be doing 2 INSERTS: one in history and one in history_diff table.

That's it! Project is very simple.

Solve this succesfully and more work is guaranteed.

Special thanx to Geroge Fountaine for his collaboration.

awarded to gabrielsimoes

Crowdsource coding tasks.

1 Solution

Excellent job!. Not only he delivered an excellent solution, but also outstanding and surprising extras. I'm looking forward to working with Gabriel if available.
Vortilon 26 days ago