Structuring Databases for Financial Statements

后端 未结 3 1394
孤城傲影
孤城傲影 2021-01-03 11:01

I am looking for the best way to structure my database. I have quarterly financial statements for 1000’s of companies from 1997-2012. Each company has three different state

3条回答
  •  [愿得一人]
    2021-01-03 11:16

    I would probably go with the following structure in one data table:

    Company
    StatementType 
    LineItem
    FiscalYear
    Q1, Q2, Q3, Q4
    

    StatementType would be Income Statement, Balance Sheet or Cash Flow Statement. Line Item would be the coded/uncoded text of the item on the statement, Fiscal Year is 2012, 2011 and so on. You'd still need to make sure that Line Items are consistent across companies.

    This structure would let you query for flat statement -

    select
    LineItem, Q1, Q2, Q3, Q4
    from Data
    where 
    Company = 'RoyalBank'
    and FiscalYear = 2012
    and StatementType = 'Income Statement'
    

    or

    QoQ

    select
    FiscalYear,
    Q1
    from Data
    where 
    Company = 'Royal Bank'
    and 
    StatementType = 'Income Statement'
    and
    LineItem = 'Sales'
    order by FiscalYear
    

    in addition to aggregates. You'd probably want to have another table for line items with some kind of an index reference to make sure you can pull the statement back in the original order of line items.

提交回复
热议问题