Click here to Skip to main content
15,881,715 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I am having a dillema.
I am not sure which is the best way to organize data in my database.
I am dealing with a very large number of objects (may be millions of them) which could be neatly arranged in some sort of a Tree.
I thought of three possible approaches:
1. Use a MAIN TABLE for the objects themselves and a large number of TABLEs for those object's fields which allow only a finite, discrete set of string values. Parentage should be explicit or inferred from the properties.
2. Use only one TABLE and store there only the object's ID and PARENT plus the fields which add something new to the parent. All the other fields (which are identical to the parent's ones) should be NULLs and their values copied from the parent when necessary.
3. Same as 2, but only one property field per object, its kind (like COLUMN) being inferred by the depth of the Node in the Tree.

Whew! And now, finally, the question:
Which approach (or other if you can think of) would be better suited for:
* Smaller database (on disk)
* Faster access (retrieval of data)
* Contructing / parsing / modifying the Tree structure.
* Ease of implementation, clarity of underlying code, standards...
(their relative importance in this order)

And... Does it matter what type of database I use (firebird, mysql, microsoft sql express, etc)?

And... Using stored PROCEDUREs makes it any faster (compared to parametrized queries)?

Anything else...?

Thank you.
Posted
Updated 18-Dec-10 5:59am
v5
Comments
Wild-Programmer 18-Dec-10 0:37am    
Think about using SQL Lite.
[no name] 18-Dec-10 9:37am    
Amit Kumar Tiwari: Add your comment as an answer and explain why he should use SQL Lite.
thatraja 20-Dec-10 0:53am    
Good question 5!
Toli Cuturicu 20-Dec-10 15:32pm    
Thanks.

1 solution

You might want to look atModel Your Data Hierarchies With SQL Server 2008[^].

I don't know if it would fit your data model, but interesting anyway.

You mention the possibility of using SqlExpress. You are aware that it has a limit of 4GB data, aren't you?

Although SqlExpress 2008 R2 ups that to 10GB.
 
Share this answer
 
Comments
Toli Cuturicu 18-Dec-10 12:12pm    
It should fit on a DVD anyway, so 4.3 GB will be a limit anyway. I have to somehow distribute the software. Downloading several GB from the Internet will not make anyone happy.
Toli Cuturicu 18-Dec-10 12:18pm    
Interesting answer. A lot to study and sadly, I do not have the software... :-( You got my Five but not ACCEPT... yet.

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