应届生求职,面试full stack developer,第二面不停地问数据库问题,本人是数据库小白,就会写写sql query什么的。请问有人知道这题怎么做吗?
大概意思就是说如何写一个sql object,使你在任何时间都可以exactly reproduce past results(因为数据库每时每刻都在改变和更新所以在不同时间抓出来的信息不一样)
总共只有两个table:
大概意思就是说如何写一个sql object,使你在任何时间都可以exactly reproduce past results(因为数据库每时每刻都在改变和更新所以在不同时间抓出来的信息不一样)
总共只有两个table:
- Dbo.data1 (main data table, primary key is on date,id_security)
- Data audit.data1 (audit table that contains history of changes. Changedate is date-time of the changes)
- 主table叫dbo.data1 ,有[date], [id_security], 和其他fields。
- 辅table叫data_audit.data1,有[id_data_audit_data1], [date], [id_security], [ChangeDate], [ChangeUser], [ChangeAction] 和其他fields。
- 每一次主table发生了变化,辅table就会记录下变化的时间,id_security,ChangeAction等等
- Create SQL object to show data in the same structure as dbo.data1 but as of certain date/time.
- Now time is 2018-02-22 14:42:22.
- I do SELECT * FROM dbo.data1 WHERE date = '2011-12-31'
- and get some records.
- In the future, even though records can be updated or deleted, if
- I do SELECT * FROM dbo.data1_PIT('2011-12-31', '2018-02-22 14:42:22')
- I will have to get identical output as I see now with the query under a.a (SELECT * FROM dbo.data1 WHERE date = '2011-12-31')
- Based on the code in triggers, I would like you to elaborate on:
- Our approach to data audits. Triggers and PIT functions are generated automatically with stored procedure, so maintenance is not a problem.
- Ideas for improvement. There is certainly room for improvement.
- Is SQL 2008/12/16 built in audit better solution? We audit just selected tables.
- Any suggestions for audit table compression and/or partitioning.
请各位大侠指点迷津,小女子感激不尽。
附件
最后编辑: 2018-04-20