Database structure for storing historical data

后端 未结 7 975
夕颜
夕颜 2020-12-13 05:48

Preface: I was thinking the other day about a new database structure for a new application and realized that we needed a way to store historical data in an efficient way. I

相关标签:
7条回答
  • When I've encountered such problems one alternative is to make the order the history table. Its functions the same but its a little easier to follow

    orders
    ------
    orderID
    customerID
    address
    City
    state
    zip
    
    
    
    customers
    ---------
    customerID
    address
    City
    state
    zip
    

    EDIT: if the number of columns gets to high for your liking you can separate it out however you like.

    If you do go with the other option and using history tables you should consider using bitemporal data since you may have to deal with the possibility that historical data needs to be corrected. For example Customer Changed his current address From A to B but you also have to correct address on an existing order that is currently be fulfilled.

    Also if you are using MS SQL Server you might want to consider using indexed views. That will allow you to trade a small incremental insert/update perf decrease for a large select perf increase. If you're not using MS SQL server you can replicate this using triggers and tables.

    0 讨论(0)
提交回复
热议问题