Click here to Skip to main content
15,900,505 members
Home / Discussions / Database
   

Database

 
AnswerRe: How to do a sequential select in a stored procedure? [modified] Pin
Damodar Periwal1-Nov-06 8:35
Damodar Periwal1-Nov-06 8:35 
QuestionInsert new rows from a dataset to Sql server database Pin
biglewy30-Oct-06 22:25
biglewy30-Oct-06 22:25 
QuestionWrite to text file from a sql server stored-procedure Pin
flippydeflippydebop30-Oct-06 20:48
flippydeflippydebop30-Oct-06 20:48 
AnswerRe: Write to text file from a sql server stored-procedure Pin
flippydeflippydebop30-Oct-06 22:38
flippydeflippydebop30-Oct-06 22:38 
AnswerRe: Write to text file from a sql server stored-procedure [modified] Pin
flippydeflippydebop30-Oct-06 22:40
flippydeflippydebop30-Oct-06 22:40 
Questioninserting values from select query Pin
dj.rock30-Oct-06 19:46
dj.rock30-Oct-06 19:46 
AnswerRe: inserting values from select query Pin
neilsolent31-Oct-06 0:54
neilsolent31-Oct-06 0:54 
QuestionHow to store an 1:N tree (Hierarchy) Pin
peterchen30-Oct-06 14:52
peterchen30-Oct-06 14:52 
What would be the best way to store a strict hierarchy (like a "Help Contents" tree) in a database?
Is there a "standard solution"?


I'm more looking for alternatives, but here's what seems most natural to me: Storing just the parent in the same table as the items

id PKey, nchar name, id PKeyOfParent

e.g.
0, "Root", 0 (predefined ID)
1, "Child1", 0
2, "Child2", 0
3, "A GrandChild", 1
4, "Another GrandChild", 2

to get all immediate childs of MyID is simply WHERE PKeyOfParent=MyID

Advantage: No redundant data, orphaned items (parent does not exist are easily found.
Disadvantages: orphaned "cycles" are possible. can SQL Server can be forced to keep integrity itself (e.g. recursively deleting all descendants?). "IsDescendant" probably cannot be written as a single select (stored procedure maybe?)

The application I'm thinking of introduces a "secondary" M:N mapping anyway, but from my judgement, a more restrictive hierarchy would help the user a lot.
Also, for the amount of data I imagine it would be no problem to read the entire index, then build the tree in the client, but that sounds just wrong.




We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP

Linkify! || Fold With Us! || sighist

AnswerRe: How to store an 1:N tree (Hierarchy) Pin
Colin Angus Mackay31-Oct-06 4:37
Colin Angus Mackay31-Oct-06 4:37 
AnswerRe: How to store an 1:N tree (Hierarchy) Pin
Damodar Periwal31-Oct-06 9:46
Damodar Periwal31-Oct-06 9:46 
AnswerRe: How to store an 1:N tree (Hierarchy) Pin
Eric Dahlvang1-Nov-06 11:31
Eric Dahlvang1-Nov-06 11:31 
QuestionMicrosoft Access VBA Question About ListBoxes... Pin
new_phoenix30-Oct-06 14:15
new_phoenix30-Oct-06 14:15 
QuestionSQL Select Puzzle Pin
neilsolent30-Oct-06 9:51
neilsolent30-Oct-06 9:51 
AnswerRe: SQL Select Puzzle Pin
Eric Dahlvang31-Oct-06 3:07
Eric Dahlvang31-Oct-06 3:07 
QuestionWhere can I lean about stored procedures? Pin
CCMint30-Oct-06 7:01
CCMint30-Oct-06 7:01 
QuestionCOPY TABLE giving unexpected EOF error Pin
Zeolite30-Oct-06 6:55
Zeolite30-Oct-06 6:55 
QuestionBest way to save data Pin
knappster30-Oct-06 1:43
knappster30-Oct-06 1:43 
QuestionADO.NET related question Pin
Imtiaz Murtaza30-Oct-06 0:57
Imtiaz Murtaza30-Oct-06 0:57 
AnswerRe: ADO.NET related question Pin
Colin Angus Mackay30-Oct-06 1:54
Colin Angus Mackay30-Oct-06 1:54 
GeneralRe: ADO.NET related question Pin
Damodar Periwal31-Oct-06 10:14
Damodar Periwal31-Oct-06 10:14 
AnswerRe: ADO.NET related question Pin
Hunuman30-Oct-06 2:02
Hunuman30-Oct-06 2:02 
GeneralData Type Issue in Where Clause Pin
Brady Kelly30-Oct-06 0:13
Brady Kelly30-Oct-06 0:13 
JokeRe: Data Type Issue in Where Clause Pin
Rob Graham30-Oct-06 3:14
Rob Graham30-Oct-06 3:14 
Questionselect query filling 2 typed datasets Pin
steve_rm29-Oct-06 22:10
steve_rm29-Oct-06 22:10 
QuestionPurpose of SQL Server Jobs Pin
King Shez29-Oct-06 19:50
King Shez29-Oct-06 19:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.