Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

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

Starting Member

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

and have similar columns for all remaining business days

Any other suggestions?


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

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

Very Important crosS Applying yaK Herder

52326 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

Go to Top of Page

Starting Member

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  
 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.05 seconds. Powered By: Snitz Forums 2000