Click here to Skip to main content
15,890,609 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Our company designing Accounting Systems which Have Chart of Accounts Of Infinite Levels And these numbers is not unique For Example

1000 / Assets

1100 / Current Assets
So I Need to make
L1 L2 L3 L4 L5 And So on.. Of infinite Levels
1100/100/200/300/100

But There`s Also 100, 200 ,300 of Another Category Called Liabilities For Example

2000 Liabilities
2100 short term liabilities

L1 L2 L3 L4 L5
SO Theres Account Like this : 2100/100/200/300/100


Finally, What i try to do is designing this accounting Table Like This :

Table Name : Account
[AccountID, ParentID, Level, Name] I Guess i make AccountID, ParentID,Level CompositeKey

The Question Is How I Know that 100 inherit from 300 inherit from 200 And Came From Liabilities 2100 ? it will also came from Parent 1100

That`s Problem maybe i cant design this well,

I know i can use Levels As String Not Integer But Big Data and big records will make queries slow For Example Inside Account Table ParentID Can Be 2100/100/200/300
And This maybe will work, but how i design these with Integer Values And Infinite Child Of Child


Another Additional Question : How I Attach This To TreeView DataSource !


Sorry, if i make you guys misunderstanding or can`t explain it well.

What I have tried:

Desiging Normal Table Of ID, ParentID, but i actually Fail.
Posted
Updated 11-May-17 0:55am
v3
Comments
Richard Deeming 11-May-17 8:20am    
Maybe the HierarchyID[^] type might help?

1 solution

Maybe you can use a many-to-many relationship, here is an example:
Data Modeling - Many-to-many Relationship [Gerardnico][^]

My database of choice (after struggling with SQL Server for years) is now PostgreSQL, it supports "multi value" fields, see: PostgreSQL: Documentation: 9.5: Composite Types[^]

But as you probably are using SQL Server, maybe XML fields would be an option, see this example: Using the FOR XML Clause to Return Query Results as XML - Simple Talk[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900