Which design would you choose for a database for the custom fee table and why?
Option 1) 1 table, UserId determines if user has custom fee
ACCOUNT_FEE
TypeId
FixedRate
VariableRate
CurrencyId
UserId (UserId is null for default account fee, UserId is present for custom fee)
Option 2) 2 separate tables, one for default fee the other for user’s custom fee
ACCOUNT_DEFAULT_FEE
TypeId
FixedRate
VariableRate
CurrencyId
USER_ACCOUNT_FEE
TypeId
FixedRate
VariableRate
CurrencyId
UserId
I would do it differently. Create a user called “Default Account” and give it a specific ID, or even “0” (identity_insert may be required). This allows the table to follow referential integrity rules AND the index on UserID can quickly pick out the Default Account Fee.
Otherwise,