100 likes | 171 Views
Consider essential data types, access methods, reconciliation techniques, traceability, logging, auditing, and user permissions for a robust financial system database design. Learn why Decimal is preferred over Float and Money, Date over DateTime, and Read Committed or RCSI over NOLOCK for data access. Ensure data traceability by passing unique IDs downstream and use HashBytes for efficient Reconciliation. Utilize history tables for auditing and prioritize group permissions over user permissions for enhanced security. Explore comprehensive guidelines to optimize your financial system database design.
E N D
Database design considerations for a financial system Louie Bao
Data Types • Date over Datetime • Most financial data such as prices, portfolio holdings, etc are date based and not concerned with the time component. • The separate Date data type introduced since SQL 2008 significantly reduces date comparison and calculation mistakes.
Data Types • Decimal over Float • Decimal is a precise numerical type whereas Float is an approximate numerical type. • Decimal over Money • Money data type suffers from integer division.
Data Access • Read Committed or RCSI over NOLOCK NOLOCK is bad because: • Uncommitted rows might be returned. • Same record might be accounted twice. • Previously committed rows might be missed. • Query might fail with an error: Could not continue scan with NOLOCK due to data movement.
Data Reconciliation • HashBytes over Checksum • When an MD5 hash algorithm is specified, the probability of HashBytes returning the same result for two different inputs is much lower than that of CHECKSUM.
Data Traceability • Pass as many IDs as far downstream as possible • FileId • AccountId • OrderId • TradeId • SecurityId • etc
Logging • Process Event Log • Info • Warning • Error • Process Progress Log • Started • Running • Completed • Process Exception Log • Invalid/unknown data
Auditing • History Tables • Keep track of who changed what when how. Audit Columns
Security • Group permission over User permission • Add and remove users with ease. • Align permissions with business functions • Testers should not have write access in prod.
References Throw Your MONEY Away http://bradsruminations.blogspot.com.au/2009/11/throw-your-money-away.html Previously committed rows might be missed if NOLOCK hint is used http://blogs.msdn.com/b/sqlcat/archive/2007/02/01/previously-committed-rows-might-be-missed-if-nolock-hint-is-used.aspx Timebomb - The Consistency problem with NOLOCK / READ UNCOMMITTED http://sqlblogcasts.com/blogs/tonyrogerson/archive/2006/11/10/1280.aspx