SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 Database Design and Application Architecture
 Designing a SQL database for stock market data
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

CSharpNewbie
Starting Member

USA
39 Posts

Posted - 12/22/2012 :  05:29:13  Show Profile  Reply with Quote
I am designing a database that will host stock market data on a daily basis. There are about 3000 ticker sybmols that I will be tracking.

One table will have the company profile (CompanyID, CompanyName, TickerSymbol, Description)

Another table would be the one with that data. I need 5 fields for each ticker symbol for each day (OpeningPrice, ClosingPrice, Volumme, PriceToEarnings, EarningsPerShare). These five fields will be required for each ticker symbol for each business day (approximately 20 business days in a month).

What would be the best way to design this table?


My initial thought is:

TableName: 2013_Jan

ColumnNames: 02_Jan_Opening
,02_Jan_Closing
,02_Jan_Volume
,02_Jan_PriceToEarnings
,02_Jan_EarningsPerShare
,03_Jan_Opening
,03_Jan_Closing
,03_Jan_Volume
,03_Jan_PriceToEarnings
,03_Jan_EarningsPerShare
,04_Jan_Opening
,04_Jan_Closing
,04_Jan_Volume
,04_Jan_PriceToEarnings
,04_Jan_EarningsPerShare

and have similar columns for all remaining business days


Any other suggestions?

Thanks

Edited by - CSharpNewbie on 12/22/2012 05:32:17

sunitabeck
Flowing Fount of Yak Knowledge

5155 Posts

Posted - 12/22/2012 :  06:27:28  Show Profile  Reply with Quote
I would strongly recommend against doing it the way you are proposing.
Think about how hard it would be if you were asked questions such as "what was the average volume last month", or "what was the lowest price during last year".

Instead create a table with Date, Opening Price, Volume etc.

I would caution against using Ticker as the primary identifier. Tickers can change, disappear (because of ticker changes, M&A's etc.), and can even be reissued to another company after a waiting period. So I would use an internal identifier as the primary identifier with ticker, cusip, sedol or any other street identifiers just being attributes. Do you have a need to keep track of ticker changes etc.? If so you will need to have validity dates for identifiers as well.


Edited by - sunitabeck on 12/22/2012 09:16:36
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52325 Posts

Posted - 12/22/2012 :  06:32:56  Show Profile  Reply with Quote
nope. better way to design would be

(OpeningPrice, ClosingPrice, Volumme, PriceToEarnings, EarningsPerShare,datevalue,tickersymbol)

so that you store per ticker the 5 fields for each day as a row like

(OpeningPrice1, ClosingPrice1, Volumme1, PriceToEarnings1, EarningsPerShare1,01-01-2013,tickersymbol1)
(OpeningPrice2, ClosingPrice2, Volumme2, PriceToEarnings2, EarningsPerShare2,01-01-2013,tickersymbol2)
(OpeningPrice3, ClosingPrice3, Volumme3, PriceToEarnings3, EarningsPerShare3,01-01-2013,tickersymbol3)
....
(OpeningPrice1, ClosingPrice1, Volumme1, PriceToEarnings1, EarningsPerShare1,02-01-2013,tickersymbol1)
(OpeningPrice2, ClosingPrice2, Volumme2, PriceToEarnings2, EarningsPerShare2,02-01-2013,tickersymbol2)
(OpeningPrice3, ClosingPrice3, Volumme3, PriceToEarnings3, EarningsPerShare3,02-01-2013,tickersymbol3)
...
(OpeningPrice1, ClosingPrice1, Volumme1, PriceToEarnings1, EarningsPerShare1,03-01-2013,tickersymbol1)
(OpeningPrice2, ClosingPrice2, Volumme2, PriceToEarnings2, EarningsPerShare2,03-01-2013,tickersymbol2)
(OpeningPrice3, ClosingPrice3, Volumme3, PriceToEarnings3, EarningsPerShare3,03-01-2013,tickersymbol3)
....

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

CSharpNewbie
Starting Member

USA
39 Posts

Posted - 12/22/2012 :  10:34:44  Show Profile  Reply with Quote
Thanks very much for your response. I agree, my initial idea was not the best way.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000