If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Flat vs Relational for stock data

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-30-07, 11:11
mwease mwease is offline
Registered User
 
Join Date: Apr 2006
Posts: 2
Flat vs Relational for stock data

Hi,

I'm trying to store stock data in a data base. All stocks will store the date, open, high, low, close. Some stocks may also have additional information stored such as P/E ratios and Debt/Equity ratios. When I first thought of this, I figured I would store the data in a few tables and have it without nulls

Table: DataTypes (this would be Open, high, low, close, p/e, ratios, etc)
DataTypeID
Name
SQLDataType (stores if the data is a VARCHAR, INT, etc)

Table: Data
FK_StockQuoteID
FK_DataTypeID
Value (VARCHAR(20) that has to be converted each time I want to access it)

Table: StockQuotes
FK_StockID
Date

So, in this case, only the data that is available for each stock is stored. However, the more I look at this design, the more I think it is stupid. Having nulls in a table is not such a bad thing. Does something like this flat table make more sense?

Table: Quotes
(pk)FK_StockID
(pk)Date
Open
High
Low
Close

Table:ExtendedQuotes (all possible values that may be stored for the stock. Some will be null)
(pk)FK_StockID
(pk)Date
PE
DebtEquity
etc

Note that new quotes will come in many times each day.

Last edited by mwease; 05-30-07 at 11:15.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On