Results 1 to 1 of 1
  1. #1
    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 12:15.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •