Reputation: 31
Hello everyone i am developing an accounts package for my company using Sql Server 2008 and VB.Net.
I need some help regarding the database design.
I have the following tables
AccountsGroupMaster
GroupId int
GroupName nvarchar(50)
ParentGroupId int
CatId int
PrimaryGroup bit
CreatedByUser nvarchar(50)
CreatedOn datetime
The above table will store the Groups for the accounts eg: Current Assets etc.
Accounts Table
AccCode nvarchar(6)
AccountName nvarchar(30)
ParentAcc nvarchar(6)
GroupId int
The above table stores the Accounts/Ledgers .
VoucherMain
VoucherNo bigint
VoucherDate datetime
DebitCredit int (0 for Credit 1 for Debit)
AccCode nvarchar(6) (Account Code to be debited/Credited)
UserID nvarchar(30)
VoucherDetails
VoucherNo bigint
SlNo int
AccCode nvarchar(6) (Debit this account if account in VoucherMain credited/ Credit this account if account in VoucherMain Debited)
Amount decimal(18, 2)
Narration nvarchar(MAX)
The above two tables store the transactions.The above two tables linked by the VoucherNo columns
Now my question is whether i should maintain all the bank accounts in the accounts table or should i have a separate table for the bank accounts. As each bank account should have its respective ledgers.
Please help me in the design of this database. thanks
Upvotes: 0
Views: 1104
Reputation: 218837
Is a BankAccount
different than an Account
? If it's a different entity entirely then it would probably call for its own table. If it's just a certain kind of Account
then it might not. In that case, there could be other options:
For example, you could add an AccountType
to the Account
table to determine which ones are BankAccount
types and which ones are not.
Or, if the difference is more than just a type flag and includes additional Account-level columns of data which are applicable only to that specific type of Account
instances, then you might make a sub-table. It would be a BankAccounts
table, but its primary key would also be a foreign key to the Accounts
table, creating an enforced 0-1 relationship between the two.
Then, whenever creating a BankAccount
record you'd first add a record to the Accounts
table, get the generated key, and use that key to add a record to the BankAccounts
table.
Upvotes: 1